LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-30-2008, 10:52 AM   #1
prakashmodi
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Rep: Reputation: 0
Question Different memory footprint on RHEL 3.0 and 4.0


Hello,

I am running following program on RHEL 3 and RHEL 4 machines and seeing major difference in memory usage by the program. It takes roughly 830KB on RHEL 3 and between 3MB to 4MB on RHEL 4. Surprisingly RHEL 4 memory usage changes at every run.

My RHEL 3 machine is
Linux torlcc06 2.4.21-9.ELsmp #1 SMP Thu Jan 8 17:08:56 EST 2004 i686 i686 i386 GNU/Linux
and RHEL 4 machine is
Linux torlce06 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
I am using gcc-3.3.3 for compilation.

My test program code looks like:
#include <iostream>
#include <iomanip>

double getProcSize();

int main()
{
std::cout << std::setprecision(8);
std::cout << "proc size at start = " << getProcSize() << std::endl;

double* p = NULL;
for (int i = 0; i < 20; i++)
p = new double[1000];

std::cout << "proc size at end = " << getProcSize() << std::endl;
sleep(100);
}

double getProcSize()
{
double result = -1.0;
char buf[256];
FILE * file;
unsigned int pages;
snprintf(buf, sizeof(buf), "/proc/%d/statm", (unsigned int) getpid());
if ((file = fopen(buf, "r")) == NULL)
{
perror("open");
return 0;
}
fgets(buf, sizeof(buf), file);
fclose(file);
sscanf(buf, "%u", & pages);
return (pages * ::sysconf(_SC_PAGE_SIZE));
}

Can someone please explain me the possible reason(s) for this? and any suggetions to resolve this will really be appriciated.

Thanks in advance.
Prakash
 
Old 09-30-2008, 11:29 AM   #2
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 32
First, do you use gcc-3.3.3 on both machines?
Are you running the program on the machine it was compiled on or do you compile on one machine and run that binary on both?

RHEL 3 = 2.4.* kernel
RHEL 4 = 2.6.* kernel

This is a pretty big change and I can think of a few reasons for the discrepancy.
- 2.6 kernel libraries that you are using may be larger than the 2.4 versions.
- 2.6 kernel may report its memory usage differently than 2.4.
- you may be running a binary compiled on 2.4 machine on the 2.6 machine or vice versa.
 
Old 09-30-2008, 12:02 PM   #3
prakashmodi
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Yes I tried to compile test program both on RHEL 3 and 4 and run on both. I used same binary to run on both platform. I am little doubtful about kernel library size, as this difference shows up in gigs in our application.
 
  


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
Check memory footprint Ephracis Programming 7 01-04-2008 02:16 AM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:57 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