rchc
asked on
How can I know how much memory my process uses?
I'm runing a program that uses a lot of memory. How can I know how much memory does it use.
I would like to print the amount of memory it uses before aborting the porgram due to lack of memory.
Thanks
I would like to print the amount of memory it uses before aborting the porgram due to lack of memory.
Thanks
What platform r u on
ASKER
I run on Solaris 5.8 or linux
I think you should keep track of your dynamic memory allocation functions - malloc, calloc, free, realloc etc
Also,
Have a look at this site
http://www.dmalloc.com
Also,
Have a look at this site
http://www.dmalloc.com
A similar question was previously asked
here's a good discussion for the same
http://www-level3.experts-exchange.com/questions/20727263/knowing-the-memory-consumption-of-my-process.html
here's a good discussion for the same
http://www-level3.experts-exchange.com/questions/20727263/knowing-the-memory-consumption-of-my-process.html
ASKER
My code is a legacy one with thousands of lines. I can't keep track of each allocation.
I'm seeking a function that can tell me the amounr of memory allocated and or the free memory.
Is there such a function?
I'm seeking a function that can tell me the amounr of memory allocated and or the free memory.
Is there such a function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As I said, the link on EE would be helpful
I am listing one of the solutions from there
Say u are using malloc for dynamic allocation
then just do this
#define malloc malloc_wrapper
malloc_wrapper ( same_arguments_as_malloc )
{
/* do the accounting */
malloc ( ... );
return ...;
}
I am listing one of the solutions from there
Say u are using malloc for dynamic allocation
then just do this
#define malloc malloc_wrapper
malloc_wrapper ( same_arguments_as_malloc )
{
/* do the accounting */
malloc ( ... );
return ...;
}