[clug] Linux max memory per process
David Gibson
david at gibson.dropbear.id.au
Thu Nov 17 04:19:40 GMT 2005
On Thu, Nov 17, 2005 at 01:48:23PM +1100, Arafangion wrote:
> On Thu, 17 Nov 2005 02:20 pm, Pearl Louis wrote:
> > Hi guys
> >
> > Just a quick question. What is the maximum memory per process that
> > you can have in Linux, both on 32-bit machines and 64-bit machines and
> > for both 2.4 and 2.6 kernels? Also, this limit includes both physical
> > RAM and virtual memory right?
>
> This is just my impression after learning C, but here goes, if I'm wrong,
> correct me.
>
> Generally, there is a unique pointer for every char that the process can
> address.
>
> Thus, when using 32-bits, there is a limit of (2^32)*CHARBITS
>
> CHARBITS is usually 8, but could be larger.
>
> This apparently turns out to be about 4 GB. For 64-bit machines, I'd expect
> that you'd be able to address an unbelievable amount of memory.
>
> If 4 GB isn't enough, there are usually tricks (One I can think of at the
> moment is to use paging).
That would be a misleadingingly simplified answer.
Certainly a 32-bit process cannot address more than 2^32 bytes of
virtual memory. However in practice some of that 32-bit address space
is reserved by the kernel and so is not usable by the process.
Exactly how much depends on the architecture and the kernel
configuration: e.g. for a ppc kernel (32 bit kernel), with the default
configuration each process can access the low 3G of address space.
The settings of the HIGHMEM configuration parameters can change that,
though. A 32-bit process on a ppc64 (64 bit kernel) can access
(4G-4k) of address space. I'm not sure what the limit is on x86.
But beyond that, it's common for a system to have administrator
controlled resource limits on how much memory of various types a
process can have mapped - see setrlimit(2).
A 64 bit process can, theoretically address 2^64 bytes of memory,
however as far as I'm aware no Linux architecture implements the
entire range. For current ppc64 kernels each process has 16TB (2^44)
of address space, for older kernels it was 2TB. For ia64, the address
space limit depends on the page size, which is a kernel configuration
option (and the address space is discontiguous just to make things
*really* confusing). Not sure what the limits are for x86_64 or
sparc64 - I imagine they'll be >1TB and substantially less than 2^64.
Again, resource limits apply in practice.
There are no theoretical limits on how much physical memory a process
may map, except that imposed by the address space size and the amount
of physical memory available to the kernel. A 32-bit machine may even
have and use > 4GB of physical memory (using HIGHMEM), although it
can't all be used in the one process. Again resource limits may cut
in first.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
More information about the linux
mailing list