Linux – What does TOP’s DATA column mean

linuxmemorytop

I'm trying to figure out the meanings of all the different classifications of memory such as VIRT, RES, SHR, AND DATA. While I generally understand the first 3, I have no idea what the DATA column means other than it's official definition as DATA = Data+Stack size (kb). How does this relate to the other 3 classifications of memory?

Best Answer

According to https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/:

That field is computed by the kernel as a difference between two variables: total_vm which is the same as VIRT and shared_vm. shared_vm is somehow similar to SHR in that it shares the definition of the shareable memory, but instead of only accounting the resident part, it contains the sum of all addressed file-backed memory. Moreover, the count is done at the mapping level, not the page one, thus shared_vm does not have the same subtlety as SHR for the modified private file-backed memory. As a consequence shared_vm is the sum of the quadrants 2, 3 and 4. This means that the difference between total_vm and shared_vm is exactly the content of quadrant 1.

The DATA column contains the amount of reserved private anonymous memory. By definition, the private anonymous memory is the memory that is specific to the program and that holds its data. It can only be shared by forking in a copy-on-write fashion. It includes (but is not limited to) the stacks and the heap2. This column does not contain any piece of information about how much memory is actually used by the program, it just tells us that the program reserved some amount of memory, however that memory may be left untouched for a long time.