LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 04: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, 08:28 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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, 09: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, 01:39 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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