Results 1 to 1 of 1
Hi !
I have a small piece of code which mallocs 1MB of memory in an infinite loop till malloc fails. The code goes like this:
Code:
void *mem;
while ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-19-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 3
Maximum malloc-able user virtual memory
Hi !
I have a small piece of code which mallocs 1MB of memory in an infinite loop till malloc fails. The code goes like this:
I'm aware that Linux uses optimistic memory allocation, i.e., malloc returns memory although there may not be enough memory available on the RAM.Code:void *mem; while (1) { mem = (void *) malloc(1024 * 1024); //1MB if (!mem) { dump_mem_info(); //Prints total memory malloced using details from /proc/<pid>/status break; }
For a 32 bit x86 machine, I can go up to 3GB with malloc. This is because of the 3GB/1GB user/kernel virtual memory split.
I'm working on a powerPC system in which malloc fails at 1.3GB. I have checked the following:
1. Resource limit (ulimit -a), and it is set to unlimited.
2. Configuration in /etc/security/limits.conf, and there is no memory limit set.
I have been desperately trying to find answers to the following questions: (I have already googled a lot before posting post):
a. Why is the virtual memory restricted to 1.3GB in the user space ? For a 32 bit machine, shouldn't 3GB be the limit ? Is this limit specific to powerPC ?
b. In general, how do I find the maximum user virtual memory limit without running the above code which I wrote ? Is there a configuration file or command to check this ?
Thanks in advance !


Reply With Quote
