LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 12: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 12:41 AM.
 
Old 07-23-2009, 09:56 AM   #2
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
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, 12: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



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 06:21 AM
Free Physical Memory manoj.linux AIX 4 04-04-2008 07:14 PM
increase free physical memory, decrease disk cache efm Linux - Hardware 4 03-30-2006 09:53 AM
Slow to boot and low free memory krisbitner Linux - Software 1 01-15-2006 05:18 AM
free physical memory saavik Solaris / OpenSolaris 7 08-26-2005 12:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05: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
Open Source Consulting | Domain Registration