Welcome! Log In Create A New Profile


Maximum malloc-able user virtual memory

Posted by Wagaboy 
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:
    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
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.

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 !

Your Email:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 10 plus 15?