Re: Maximum amount of dynamic memory allocattion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pharaoh . escreveu:
Hi

I have a machine with 1 GB RAM and 1 GB swap area and it is a 32-bit machine. For fun, I tried to allocate memory dynamically by using malloc in a loop till there is no memory avilable. I ended up allocating 2 GB memory. My inference is, total memory
allocated can be equal to size of RAM + size of SWAP at max.

Afaik, for a 32 - bit machine we can not address more than 2^32 addresses. Now, If I have another machine with 1 GB RAM and 4 GB swap then, as per above inference I should be able to allocated 5 GB memory at max ! Out of this only lower 4 GB will be
addressable.

Is there some loophole in the above argument?

Yes. The kernel establishes a virtual address space for a given process of
4GB (and map both the kernel and the app code/data within this area).
This way you will not be able to allocate 5GB no matter how much RAM or
swap you have.

Fabiano

Regards,
Pharaoh.



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux