LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find total memory usage of a program? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-total-memory-usage-of-a-program-833704/)

Uni616 09-22-2010 01:49 AM

How to find total memory usage of a program?
 
Hello, I wrote a program that multiplies 2 matrices using multi-threads and another one using multiple processes and shared memory. Both in C.
I need to find the total memory usage of these programs. I know of the top command, but when my matrices are relatively small they don't even show up on top because they complete so fast, how can I find the memory usage for these instances?
Also, how can I find the total turnaround time of my programs?

Any help would be appreciated, thanks in advance.

Tinkster 09-22-2010 02:24 AM

Have a look at valgrind .. may be sufficient.

Uni616 09-22-2010 06:57 PM

Thanks a lot! That had just what I was looking for.

quanta 09-22-2010 09:43 PM

You can use pmap or:
Code:

ps -eo size,pid,user,cmd | grep <process_name> | grep -v grep | awk '{ m+=$1 } END { print m }'


All times are GMT -5. The time now is 03:54 PM.