在 64 位 Linux 操作系统上运行的 32 位进程的内存限制 [英] Memory limit to a 32-bit process running on a 64-bit Linux OS

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

问题描述

32 位进程在 64 位 Linux 上可以有多少虚拟内存(即,在开始获取 NULL 指针之前,我可以通过 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)?

我在我的 32 位 Linux 上尝试过,达到了大约 3 GB 的限制.我能在 64 位 Linux 上获得更多吗?

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?

推荐答案

在标准的 32 位 x86 smp 内核中,每个进程可以使用 4GB 地址空间中的 3GB,1GB 由内核使用(共享地址空间每个过程).

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).

使用 4G/4G 分离的hugemem"32 位 x86 内核,每个进程可以使用(几乎)整个 4GB 的地址空间,并且内核有单独的 4GB 的地址空间.Red Hat 在 RHEL 3 和 4 中支持该内核,但他们在 RHEL 5 中放弃了它,因为主线内核不接受该补丁,而且现在大多数人仍然使用 64 位内核.

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.

使用 64 位 x86_64 内核,32 位进程可以使用整个 4GB 地址空间,除了由内核管理的 4GB 地址空间末尾的几个页面 (8KB).内核本身使用了超出 4GB 可供 32 位代码访问的地址空间的一部分,因此它不会减少用户地址空间.64 位进程可以使用更多的地址空间(RHEL 6 中为 128TB).

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).

请注意,某些地址空间将被程序代码、库和堆栈空间使用,因此您将无法malloc() 整个地址空间.这些东西的大小因程序而异.查看 /proc//maps 以了解地址空间在您的进程中是如何使用的;您可以malloc() 的数量将受到最大未使用地址范围的限制.

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.

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

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