LinuxQuestions.org
Help answer threads with 0 replies.
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 06-27-2014, 05:15 PM   #1
gupr1980
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
malloc


I see there is mallocoptions=disclaim that can be set on AIX for an ID. Then unused memory will be returned to the server from any processes that runs on that ID.

Is there a similar setting on Linux. On our Linux server, the process memory usage keeps growing. This is because,eventhough there is memory available from previous run of the program. the program expects contiguous memory blocks which is not available hence it goes back to the physical memory and asks for more. This results in memory growing for ever slowly.

On AIX when this mallocoptions=disclaim is set, unused memory is returned after the application stops and memory is got back form physical memory each time. I know it is a performance hit but it is better than a holding memory for nothing.
 
Old 06-27-2014, 09:28 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
If a process is terminated, all of its memory will be reclaimed by the OS. If your system continuously asks for more memory, it might have a memory leak. You can use a tool called Valgrind to check for this.
 
Old 06-27-2014, 10:35 PM   #3
gupr1980
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
The way the application runs is, the process is always running. It's multi threaded. The threads use memory and returns back
To process. Next time the thread processes, it requires memory but the memory returned is not good because it is fragmented. It needs contiguous memory. Hence the process gets more memory. This happens over and over again causing memory spike. If there was a way the process could return memory that wud be great.
 
Old 06-28-2014, 02:39 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
You can't.

If memory is fragmented as described, it can't be deallocated... If it is not fragmented, you will get a chunk of the desired size.

The memory management already combines freed memory blocks (making a larger block) IF they are adjacent.
 
  


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
malloc anoosh Programming 1 03-15-2006 05:41 PM
malloc eagle683 Programming 6 05-22-2005 03:40 PM
malloc in c programming saiz66 Programming 18 10-04-2004 03:00 PM
malloc() vijeesh_ep Programming 4 08-25-2004 04:50 PM
about malloc eshwar_ind Programming 11 02-18-2004 04:41 PM


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