From: Gennady Bystritsky Date: 2009-07-24T17:28:13+09:00 Subject: [C/Linux] How to get amount of allocated memory from within a process (heap size) What would be a good way to determine the current heap size (VSZ) for a process on Linux? I always used sbrk(0) for that, which used to return the top of the heap. However recently, to my dismay, I discovered that it does not work on Linux -- I successfully malloc()-ed 1GB, could confirm it with "ps -o pid,vsz,args", and yet sbrk(0) always returns the same value as right in the beginning. As a work around, I have to open /proc//stat and read out the 23d field from there. However it is heavy and ugly, and I have a feeling that such a thing should be done in a more elegant way. Please help. Any suggestions will be greatly appreciated. I even tried to play with mallinfo(), however could not figure out how to interpret results. Thank you, Gennady Bystritsky.