是什么决定了多少内存可分配? [英] What determines how much memory can be allocated?

查看:149
本文介绍了是什么决定了多少内存可分配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个后续我的previous问题为什么为size_t是必要的。

This is a follow-up to my previous question about why size_t is necessary.

由于为size_t是保证的<击>最小整数大到足以重新present的内存,你可以分配(意思是块的最大尺寸也可以采取一些整数比为size_t大),我的问题是...

Given that size_t is guaranteed to be the smallest integer big enough to represent the largest size of a block of memory you can allocate (meaning there can still be some integers bigger than size_t), my question is...

是什么决定了你多少可以分配一次?

What determines how much you can allocate at once?

推荐答案

你的机器的体系结构,操作系统(但两者相互交织)和你的编译器/库集决定了你能有多少内存分配一次。

The architecture of your machine, the operating system (but the two are intertwined) and your compiler/set of libraries determines how much memory you can allocate at once.

的malloc 需要以能够使用所有的操作系​​统可以给他的记忆。 OS不需要,以使现有机器(和Windows Server的各种版本,例如有不同的最大内存全部内存present的许可证的原因 的)

malloc doesn't need to be able to use all the memory the OS could give him. The OS doesn't need to make available all the memory present in the machine (and various versions of Windows Server for example have different maximum memory for licensing reasons)

但需要注意的是,OS的可以使提供比本机中的present更多的内存,并且一个比由主板允许甚至更多的内存(比方说主板有一个单一的只接受1GB的记忆棒内存插槽,可以的Windows仍然让一个程序分配内存2GB)。这是throught使用虚拟内存,分页(你知道,交换文件,你又老又慢的朋友:-)或完成,例如,通过使用的 NUMA

But note that the OS can make available more memory than the one present in the machine, and even more memory than the one permitted by the motherboard (let's say the motherboard has a single memory slot that accepts only 1gb memory stick, Windows could still let a program allocate 2gb of memory). This is done throught the use of Virtual Memory, Paging (you know, the swap file, your old and slow friend :-) Or, for example, through the use of NUMA.

这篇关于是什么决定了多少内存可分配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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