空间限制为32位程序运行在64位Linux操作系统 [英] Memory limit to a 32-bit process running on a 64-bit Linux OS

查看:699
本文介绍了空间限制为32位程序运行在64位Linux操作系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多少虚拟内存可以在32位进程对64位Linux (即有多少内存可我分配和使用malloc()开始之前,我得到一个 NULL 指针)<? / P>

我想它在我的32位Linux和达到约3 GB的限制。我能得到更多的64位Linux?

解决方案

在标准的32位x86 SMP内核,每个进程可使用4GB的地址空间,3GB和1GB用于内核(在地址空间共享每个进程)的。

随着4G / 4G分裂的hugemem32位x86内核,每个进程可以使用(几乎)地址空间的整个4GB和内核的地址空间,一个独立的4GB。这个内核是由Red Hat在RHEL 3和4的支持,但他们放弃了它在RHEL 5,因为该补丁不被接受到主线内核和大多数人使用的64位内核现在反正。

使用64位x86_64的内核,一个32位的过程中可以使用整个4GB的地址空间,除了几页(8KB),在该被内核管理4GB的地址空间的末端。内核本身使用的地址空间超出4GB访问32位code的一部分,因此它不降低用户的地址空间。 64位进程可以使用更多的地址空间(128TB在RHEL 6)。

请注意,某些地址空间将被用于程序code,库和堆栈空间,所以你将不能够的malloc()你的整个地址空间。这些东西的大小程序而异。看看的/ proc /&LT; PID&GT; /图怎么看的地址空间正在以你的过程中使用;量可以的malloc()将最大的未使用的地址范围是有限的。

How much virtual memory can a 32-bit process have on 64-bit Linux (i.e. how much memory can I allocate and use with malloc() before I start getting a NULL pointer)?

I tried it on my 32-bit Linux and reached about 3 GB limit. Will I be able to get more on 64-bit Linux?

解决方案

In the standard 32-bit x86 smp kernel, each process can use 3GB of the 4GB address space and 1GB is used by the kernel (shared in the address space of each process).

With the 4G/4G split "hugemem" 32-bit x86 kernel, each process can use (almost) the entire 4GB of address space and the kernel has a separate 4GB of address space. This kernel was supported by Red Hat in RHEL 3 and 4, but they dropped it in RHEL 5 because the patch was not accepted into the mainline kernel and most people use 64-bit kernels now anyway.

With the 64-bit x86_64 kernel, a 32-bit process can use the entire 4GB address space, except for a couple pages (8KB) at the end of the 4GB address space which are managed by the kernel. The kernel itself uses a part of the address space that is beyond the 4GB accessible to 32-bit code, so it does not reduce the user address space. A 64-bit process can use much more address space (128TB in RHEL 6).

Note that some of the address space will be used by the program code, libraries, and stack space, so you won't be able to malloc() your entire address space. The size of these things varies by program. Take a look at /proc/<pid>/maps to see how the address space is being used in your process; the amount you can malloc() will be limited by the largest unused address range.

这篇关于空间限制为32位程序运行在64位Linux操作系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆