内存分配问题 [英] memory allocation issues

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

问题描述

我有以下问题 我的计算机上有2.5 GB的RAM,如果有可能将全部内存分配给某个进程,例如 char * buffer=malloc(2.4GB),是否无法运行其他进程(谷歌浏览器,计算机中的Microsoft游戏等)?

i have following question i have RAM 2.5 GB in my computer what i want is if it is possible that in case of allocate totally memory to some process or for example char * buffer=malloc(2.4GB) , no more process ( google chrome, microsoft games in computer..etc) can run?

推荐答案

在Windows之类的操作系统中,每个进程都获得4GB(假定32位操作系统)虚拟地址空间,您拥有多少RAM无关紧要.在这种情况下,malloc(2.4GB)肯定会失败,因为用户地址空间仅限于2GB.甚至分配2GB也会很有可能失败,因为系统必须为malloc分配2GB的 continuos 虚拟地址空间.由于碎片,这种连续不断的空闲内存几乎是不可能的.

In a OS like Windows where each process gets a 4GB (assuming 32 bit OS) virtual address space, it doesn't matter how much RAM you are having. In such a case malloc(2.4GB) will surely fail as the user address space is limited to 2GB only. Even allocating 2GB will most probably fail as the system has to allocate 2GB of continuos virtual address space for malloc. This much continous free memory is nearly impossible due to fragmentation.

这篇关于内存分配问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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