Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-22-2010, 02:49 AM   #1
LQ Newbie
Registered: Sep 2010
Posts: 7

Rep: Reputation: 0
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.
Old 09-22-2010, 03:24 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
Have a look at valgrind .. may be sufficient.
Old 09-22-2010, 07:57 PM   #3
LQ Newbie
Registered: Sep 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks a lot! That had just what I was looking for.
Old 09-22-2010, 10:43 PM   #4
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
You can use pmap or:
ps -eo size,pid,user,cmd | grep <process_name> | grep -v grep | awk '{ m+=$1 } END { print m }'


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find total apache memory usage? j0hnsmith Linux - Server 7 09-13-2010 03:49 AM
Query: Embedded System - Total Memory Usage EmbeddedSteve Linux - Embedded & Single-board computer 1 08-20-2010 01:40 PM
most, er, universal way to get system memory total and usage lumix Linux - Newbie 1 06-03-2007 10:30 AM
Command to show each application/process memory usage and its total gn00kie Linux - Enterprise 2 09-21-2006 04:08 AM
Limiting the total amount of memory usage by apache. Linux - General 8 08-30-2002 10:56 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration