LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-03-2009, 12:52 PM   #1
Gamma_User
LQ Newbie
 
Registered: Jan 2009
Location: Brazil, Curitiba
Distribution: Debian
Posts: 19

Rep: Reputation: 0
Is it possible to know the amount of memory used by a program before running it?


I would like to know if there is a linux command to verify the amount of memory used by a program. The programs I am using were compiled with gfortran.

Last edited by Gamma_User; 03-03-2009 at 12:58 PM.
 
Old 03-03-2009, 01:07 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
That problem is not decidable. It's not possible to write a static analysis tool to find out how much memory a program uses. However, if you wrote the program, you really should have a decent estimation of how much memory it uses. If you need to know more specifically how much (like if you've just implemented a space-for-speed optimization, and can only estimate it'll take at least an order of magnitude more space), run 'top', sort by memory consumption and watch for your process. I've found that if you use more than about 50% of the total memory in the system, you are in danger of swap-thrashing.

Of course, all of this depends on whether the program is written in a language in C or C++ where you actually can care about resources.
 
Old 03-03-2009, 02:14 PM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Without running it ? Well, the only way in that case it to examine the source code, but that only works for languages that let you do the memory allocations
 
  


Reply



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
view memory of a quick running program youwin Linux - General 3 02-26-2009 08:38 PM
What should be the ideal memory amount for swap? dnskdas Linux - Newbie 13 12-07-2008 04:22 AM
check amount of memory naijaguy Linux - General 4 10-15-2008 02:11 PM
Gnome System Tray Show Program Running in Memory help nedson Linux - Newbie 1 04-20-2006 08:21 PM
I need to know the exact amount of static memory being reserved by my program in C grupoapunte Programming 2 05-06-2005 10:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:27 AM.

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