What does 'dirty-flag' / 'dirty-values' mean?

piotrek picture piotrek · Nov 21, 2012 · Viewed 22.5k times · Source

I see some variables named 'dirty' in some source code at work and some other code. What does it mean? What is a dirty flag?

Answer

Dietmar Kühl picture Dietmar Kühl · Nov 21, 2012

Generally, dirty flags are used to indicate that some data has changed and needs to eventually be written to some external destination. It isn't written immediate because adjacent data may also get changed and writing bulk of data is generally more efficient than writing individual values.