LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-23-2009, 01:40 AM   #1
FEWP
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Can't malloc all free physical memory, CommitLimit too low


Hi all. I'm writing some code to make a custom Ubuntu 8.04 Live CD and the code will write the character "x" to all free physical memory. In a shell script, I turn off swapping (swapoff), turn off overcommit (echo 2 > /proc/sys/vm/overcommit_memory), drop_cache, check MemFree in /proc/meminfo and pass the value to a simple C program that malloc's a buffer with the size of that value. But I'm unable to allocate that amount because I think my CommitLimit shown in /proc/meminfo is 700mb out of the 1.4gb MemFree (1.5gb MemTotal). In the C code, the malloc returns a null pointer when I pass it anything greater than the value of CommitLimit, which is consistent with what I think is causing the null pointer.

Is there a way to increase the CommitLimit so I can allocate every bit of the free space? Again the script and C code is being run from a LiveCD environment, so there is no physical hard disk.

Last edited by FEWP; 07-23-2009 at 01:41 AM.
 
Old 07-23-2009, 10:56 AM   #2
orgcandman
Member
 
Registered: May 2002
Location: dracut MA
Distribution: Ubuntu; PNE-LE; LFS (no book)
Posts: 594

Rep: Reputation: 102Reputation: 102
In short: no. The design of linux memory allocator is to always be optimistic, and therefore you cannot prevent the OOM killer from running, or from exceeding the commit limit in an allocation. I could be wrong on this, but that is my assumption on how the linux allocation scheme works.
 
Old 07-23-2009, 01:56 PM   #3
FEWP
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0
You can turn off the optimistic allocation as described (echo 2 > /proc/sys/vm/overcommit_memory). This will indirectly prevent the OOM killer from running, in theory, by not preventing memory allocation calls from getting more than they're supposed to. However I'm wondering how the kernel arrives at the CommitLimit value. It seems odd that it would only be about half the amount of MemFree.
 
  


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
PCIe dma-able memory location in physical memory for Intel Nehalem / Tylersburg arch robvoo Linux - Kernel 4 07-31-2009 07:21 AM
Free Physical Memory manoj.linux AIX 4 04-04-2008 08:14 PM
increase free physical memory, decrease disk cache efm Linux - Hardware 4 03-30-2006 10:53 AM
Slow to boot and low free memory krisbitner Linux - Software 1 01-15-2006 06:18 AM
free physical memory saavik Solaris / OpenSolaris 7 08-26-2005 01:22 PM


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