Memory usage of current process in C
c, linux, memory, memory-management, php-extension
Solution
You can always just open the 'files' in the `/proc` system as you would a regular file (using the 'self' symlink so you don't have to look up your own pid):
FILE* status = fopen( "/proc/self/status", "r" );
Of course, you now have to parse the file to pick out the information you need.
Problem
I need to get the memory usage of the current process in C. Can someone offer a code sample of how to do this on a Linux platform? I'm aware of the `cat /proc/<your pid>/status` method of getting memory usage, but I have no idea how to capture that in C. BTW, it's for a PHP extension I'm modifying (granted, I'm a C newbie). If there are shortcuts available within the PHP extension API, that would be even more helpful.