LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 01-02-2008, 08:44 PM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
Check memory footprint


Hi.

I've just written a small program that uses my own library. I would like to see the memory this application uses, including my own library.

I uses a couple of other libraries as well (Qt, libtar, libxml2) so I would like to be able to see both how much the application itself uses, and how much my library is using.

Any easy way to do that?

Thanks for any reply.
 
Old 01-02-2008, 08:50 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Easy might be relative, but have a look at /proc/<pid>/smaps
 
Old 01-02-2008, 09:19 PM   #3
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by syg00 View Post
Easy might be relative, but have a look at /proc/<pid>/smaps
Seems like what I am looking for. I found a perl script but I didn't get it to work on Ubuntu Gutsy, tho. Had to install a number of extra perl libraries.

Any tips on a good script to view all this info which is easy to get working under ubuntu?
 
Old 01-02-2008, 09:36 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
smaps.pl ??? Should only need Smaps from CPAN.
Worked for me when I finally got a kernel at the right level. Was a while ago though - looking around I can't find it now, so that system must have been the subject of a rebuild.
 
Old 01-02-2008, 09:47 PM   #5
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by syg00 View Post
smaps.pl ??? Should only need Smaps from CPAN.
Worked for me when I finally got a kernel at the right level. Was a while ago though - looking around I can't find it now, so that system must have been the subject of a rebuild.
No, it was a script called smem.pl, and I tried to install this Linux::SMAPS but all I got was an archive with pm, a t file and some other stuff. But no install instructions, the readme was only documentation of the actual library. So I had no idea how to install that.

Anyway, I found some python script which showed me private memory and shared memory of every running progress.. Running it once normally and once with the loading of my library commented out in my app I could easily calculate the size of the library to be not much more than just a couple of Kb. So I have nothing to worry about just yet.

btw, is there a good way to find out if I am freeing all the memory I've allocated? I may have missed a few destructors. :P
 
Old 01-03-2008, 02:13 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Sounds like you aren't used to Perl modules - there is doco on CPAN; here
 
Old 01-03-2008, 10:39 AM   #7
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by syg00 View Post
Sounds like you aren't used to Perl modules - there is doco on CPAN; here
Haha, exactly this should have been distributed inside an INSTALL file. :P Thanks!

EDIT: so when I ran make test I got this: Can't locate Class/Member/HASH.pm. Seems like a bit too much trouble just to get that script working. They should create a dependency solver of some sort. Or integrate perl modules into apt. :P

Last edited by Ephracis; 01-03-2008 at 10:41 AM.
 
Old 01-04-2008, 02:16 AM   #8
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
Well, that's one way of doing it. I usually start by using the CPAN install tool, which handles dependencies thus:

su -
perl -e shell -MCPAN
cpan> install This::module

etc
 
  


Reply


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
LXer: Reducing the Schedstat Memory Footprint LXer Syndicated Linux News 0 10-20-2007 08:00 PM
X11 memory footprint otoomet Linux - Software 4 09-30-2007 05:03 PM
Kernel memory footprint and analysis. unreal128 Linux - General 2 09-09-2007 03:29 PM
LXer: Reduce your Linux memory footprint LXer Syndicated Linux News 0 02-03-2007 01:33 AM
small memory footprint grcunningham Linux - Software 1 05-26-2004 08:38 AM


All times are GMT -5. The time now is 07:21 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration