program memory usage

A

Alessandro Basili

I'm facing a memory problem, since from time to time the memory usage of
my program (shown with ps and/or top utilities) increases.

I'm aware of the getrusage function from the GNU C library, but
unfortunately the kernel we are using (linux 2.6) is not supporting the
fields for memory usage in the rusage structure.

Through some research I start to use the /proc file system and the statm
file related to the pid of the running program.
Now I have inserted throughout the program several calls to a function
that prints the statistics from the statm file in order to isolate the
increase of memory usage.

Unfortunately the result points to a part of the program that does not
have any hidden ambiguities related to memory usage, which is also
confirmed by isolating it in a test program.

What I would like to understand is if the system calls to update statm
may be totally asynchronous with the current program flow (buffering,
threading??) and if that is the case how can I get the usage of the
memory reliably.

Thanks for any suggestion.

Al
 
E

Eric Sosman

I'm facing a memory problem, since from time to time the memory usage of
my program (shown with ps and/or top utilities) increases.

I'm aware of the getrusage function from the GNU C library, but
unfortunately the kernel we are using (linux 2.6) is not supporting the
fields for memory usage in the rusage structure.

Through some research I start to use the /proc file system and the statm
file related to the pid of the running program.
Now I have inserted throughout the program several calls to a function
that prints the statistics from the statm file in order to isolate the
increase of memory usage.

Unfortunately the result points to a part of the program that does not
have any hidden ambiguities related to memory usage, which is also
confirmed by isolating it in a test program.

What I would like to understand is if the system calls to update statm
may be totally asynchronous with the current program flow (buffering,
threading??) and if that is the case how can I get the usage of the
memory reliably.

Try your question on a Linux or POSIX forum. None of the things
you're asking about: getrusage, /proc, statm, threads, pids, ... are
part of the C language or library, but are defined by the particular
systems that provide them.
 
P

Phil Carmody

Eric Sosman said:
Try your question on a Linux or POSIX forum. None of the things
you're asking about: getrusage, /proc, statm, threads, pids, ... are
part of the C language or library, but are defined by the particular
systems that provide them.

If it smells like a leak, and looks like a leak, no matter what
platform it's on, there's a good chance he's got a memory leak.
So he should just grab the bull by the horns, and get a malloc
debugger that can detect leaks. Of course, that will also be
platform specific.

And complaining that the kernel doesn't have certain features
enabled is a bit lame - just recompile with them enabled. Booting
your own kernel on any sane hardware is utterly trivial nowadays.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top