Advertisement

What the.... (mem usage of my test-app)

Started by February 06, 2006 04:50 PM
2 comments, last by eedok 18 years, 8 months ago
I'm looking into ways of minimizing memory consumption of my software and right now I'm trying a certain new idea of mine. But before I implemented it I compilied a program that doesn't do ANYTHING expect include the unistd.h POSIX-header and then calls wait(1000); to see the mem usage of a "blank" app.

// libsplit.cc ----------------------

#include "unistd.h"
#include "object.hh"

int main()
{
 sleep(1000);
} // end int main()

// object.hh ---------------------

#ifndef _OBJECT_HH_
#define _OBJECT_HH_

class cObject
{
	public:
	char name[20];
}; // end class cObject

#endif




And to my shock Gnome-System-Monitor reports:

Memory: 7.5 MB
Virtual Memory: 11.4 MB
Resident Memory: 7.5 MB
Not that much but crazy for a program that doesn't do anything! Also gPS (another system monitor) reports the same values as Gnome-System-Monitor so there is nothing wrong with GSM. For comparison the usage of Fluxbox:

Memory: 2.7 MB
Virtual Memory: 6.5 MB
Resident Memory: 2.5 MB
And my hacked version of AEWM++ (which is much simpler then Fluxbox):

Memory: 1.8 MB
Virtual Memory: 11.5 MB
Resident Memory: 8.1 MB
So obviously there is something wrong with my compiler-linker setup. Ive tried compiling using both

g++ libsplit.cc -o libsplit -g -02 -march=i686 -Wall
and letting Scons decide for it self. In both cases the results are identical. Any ideas?
I'm guessing that gPS and Gnome-System-Monitor are graphical frontends for ps? If so ps isn't the best way to judge memory usage on linux.

Also try compiling without debugging info enabled (drop the -g flag) and see if you get different results.
Advertisement
Yep, try it without the -g. But most likely the problem is that you app isn't really using that much memory, that's just what is mapped into it's virtual memory space.
try the -s flag instead of the -g flag to get more accurate memory results.

This topic is closed to new replies.

Advertisement