LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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:59 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.
 
Old 03-03-2009, 09:04 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Basically... no.

Although FORTRAN may be somewhat of a simple case because it doesn't really know about "dynamic" memory-allocation, estimates of memory usage "in advance" are both difficult and not particularly useful.

What you can say about FORTRAN is that, once you obtain instrumentation of a particular program-run, "every subsequent run will be pretty-much the same."
 
Old 06-14-2009, 08:38 AM   #3
telemeister
Member
 
Registered: Dec 2007
Location: Brisbane Australia
Distribution: Slackware
Posts: 63

Rep: Reputation: 16
Agree with sundialsvcs that it is fairly difficult to get meaningful numbers..

However, you can get an idea of memory usage in a fortran program by using 'top' with and without the program running. It is a little tricky though.

For example, for top to show the memory being used by an array, you actually have to be using the array while you run top. Hence you have to gludge your code with something to force this to happen while you look at top.

e.g. in this example the while statement will force the array to be used until you bomb out of the program. Top will show you that the program is using about 1000000*4 bytes

program sizer
integer array(1000000)
do while(.true.)
array(1)=1.0
enddo
end

(Obviously, dont do this while others want to use the machine.. it will hog everything!)

Hope this helps

steve
 
  


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
Is it possible to know the amount of memory used by a program before running it? Gamma_User Programming 2 03-03-2009 02:14 PM
view memory of a quick running program youwin Linux - General 3 02-26-2009 08:38 PM
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 07:20 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