LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 03-31-2009, 10:40 AM   #1
saleem_ak
LQ Newbie
 
Registered: Apr 2007
Posts: 10

Rep: Reputation: 0
32 bit Application on 64 bit Linux OS -- Memory Usage


Hi,

I am running a 32 bit application on a 64 bit CentOS. I am seeing lot of Virtual Memory being used up by the application, which is not decreasing after the application has completed its operation. Is this anything to do with the 32 bit application running on 64 bit OS.
I did do a valgrind analysis of the application and found no major leaks, the virtual memory is reaching 4GB, before my application is getting killed.

Regards
Saleem
 
Old 03-31-2009, 11:34 AM   #2
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,142

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
Quote:
Originally Posted by saleem_ak View Post
Is this anything to do with the 32 bit application running on 64 bit OS.
I did do a valgrind analysis of the application and found no major leaks, the virtual memory is reaching 4GB, before my application is getting killed.
The fact that it can reach 4GB, rather than aborting at 3GB, is because you are running a 32bit application on a 64 bit OS. (There are also some 32bit Linux kernels that can let an application have a full 4GB, but it isn't typical).

It is very unlikely that the 64bit kernel is a factor either in some memory leak you haven't detected or in something like the malloc system failing to return memory to the OS after the application frees the memory. Malloc returning freed memory all the way back to the OS is a complicated issue. It certainly isn't a guaranteed behavior.

It is possible that a large chunk of the memory is unused demand zero memory: When the application asks malloc for a tiny amount of memory, malloc asks the OS for a much larger amount, then it parcels out that large allocation to subsequent application requests for small amounts. If the application continues to want more, malloc will ask for an even bigger chunk from the OS each time the last chunk runs out. Pretty soon it will ask for the biggest chunk the OS can give. In a 32bit app in a 32bit OS that may bring the total to nearly 3GB, while the same 32bit app at the same moment in a 64bit OS may jump to nearly 4GB. If that happens to be nearly the end of the app's increase in memory use, the VIRT size of the app will show that 3GB or 4GB value even though the memory isn't really being used (the allocation takes neither physical ram nor swap space).
 
Old 04-01-2009, 01:46 PM   #3
saleem_ak
LQ Newbie
 
Registered: Apr 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Hi John,

Thank you for your response, is there any thing extra that we have to do other than free of the memory to make sure that the memory is returned to OS.

Regards
Saleem
 
Old 04-01-2009, 03:59 PM   #4
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,142

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
When it is possible for malloc to return memory to the OS, I have no idea what settings under your control might influence whether it will do so.

But you should also consider that it might not be possible for malloc to return the memory. If your program mixes a few allocations that will be kept after the large operation completes with a lot of allocations that are freed, the heap will end up fragmented so that malloc cannot return memory to the OS.

If you want to make sure a large amount of memory can be returned, you should group together any longer term allocation, if possible before the short term allocations.
 
  


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
64 bit cpu-64 bit Ubuntu-are there 32 bit app issues? sofasurfer Ubuntu 7 04-09-2014 03:02 PM
compiling 32 bit application on 64 bit linux(x86_64) uttam_h Linux - Software 16 07-19-2008 03:33 PM
porting of 32 bit application on 64 bit linux architecture vikaschoudhry1985 Linux - Newbie 2 07-13-2008 11:39 PM
64-bit or 32-bit Application on 64-bit Linux jjana123 Linux - General 4 05-06-2008 06:27 PM
Memory bus is 64 bit but data access and register is only 32 bit for i386 lilzz Linux - Newbie 3 09-02-2006 01:35 AM


All times are GMT -5. The time now is 09:26 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration