Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process memory limit and address space for UNIX and Linux and Windows

what is the maximum amount of memory for a single process in UNIX and Linux and windows? how to calculate that? How much user address space and kernel address space for 4 GB of RAM?

like image 373
user2815465 Avatar asked Sep 18 '25 13:09

user2815465


1 Answers

How much user address space and kernel address space for 4 GB of RAM?

The address space of a process is divided into two parts,

User space: On standard 32 bit x86_64 architecture,the maximum addressable memory is 4GB, out of which addresses from 0x00000000 to 0xbfffffff = (3GB) meant for code, data segments. This region can be addressed when user process executing either in user or kernel mode.

Kernel space: Similarly, addresses from 0xc0000000 to 0xffffffff = (1GB) are meant for virtual address space of the kernel and can only addressed when the process executes in kernel mode.

This particular address space split on x86 is determined by the value of PAGE_OFFSET. Referring to Linux 3.11.1v page_32_types.h and page_64_types.h, page offset is defined as below,

#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)

Where Kconfig defines a default value of default 0xC0000000 also with other address split options available.

Similarly for 64 bit,

#define __PAGE_OFFSET _AC(0xffff880000000000, UL).

On 64 bit architecture 3G/1G split doesn't hold anymore due to huge address space. As per the source latest Linux version has given above offset as offset.

When I see my 64 bit x86_64 architecture, a 32 bit process can have entire 4GB of user address space and kernel will hold address range above 4GB. Interestingly on modern 64 bit x86_64 CPU's not all address lines are enabled(or the address bus is not large enough) to provide us 2^64 = 16 exabytes of virtual address space. Perhaps AMD64/x86 architectures has 48/42 lower bits enabled respectively resulting to 2^48 = 256TB / 2^42= 4TB of address space. Now this definitely improves performance with large amount of RAM, at the same time question arises how it is efficiently managed with the OS limitations.

like image 84
Sunil Bojanapally Avatar answered Sep 22 '25 10:09

Sunil Bojanapally