如何创建一个使用5Gb内存的进程? [英] How to create a process that uses 5Gb of memory?

查看:135
本文介绍了如何创建一个使用5Gb内存的进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个独立于平台的程序,该程序会耗尽至少
至少5Gb的内存用于测试目的。我该怎么做?


谢谢!


P

I want to write a platform independent program that would use up at
least 5Gb of memory for testing purposes. How would I do that?

Thanks!

P

推荐答案

P写道,在03/08/07 21:56:
P wrote, On 03/08/07 21:56:

我想编写一个平台无关的程序,用完了

至少5Gb内存用于测试目的。我该怎么办?
I want to write a platform independent program that would use up at
least 5Gb of memory for testing purposes. How would I do that?



它不是非常独立于平台,因为大多数平台没有5GB内存和许多可能不会允许的内存抓住这个过程来获得
那么多。对于那些尝试mallocing 5GB块的平台,如果失败则尝试
尝试mallocing 1GB 5次。确保你也写信给

内存,否则你可能没有报道的内容。


请注意,我发现很难理解为什么你需要耗尽这么多记忆

用于测试目的。

-

Flash Gordon

It won''t be very platform independent since most platforms do not have
5GB of memory and many that might will not allow one process to grab
that much. For those platforms that do then try mallocing a 5GB chunk,
if that fails try mallocing 1GB 5 times. Make sure you also write to the
memory otherwise you might not have what has been reported.

Mind you, I find it hard to see why you need to use up that much memory
for testing purposes.
--
Flash Gordon


2007-08-06 08:18,Richard< rg **** @ gmail.comwrote:
On 2007-08-06 08:18, Richard <rg****@gmail.comwrote:

现在是一个字节的字符?我失去了轨道。
Is a char a byte now? I lose track.



A" byte"在C-speak中,至少自C89以来被定义为char

所占据的空间。

在其他情况下,字节表示字节。可以有不同的定义(例如,

恰好8位)。


hp


- -

_ | Peter J. Holzer |我知道我会尊重海盗

| _ | _)|系统管理员WSR |他的肩膀上有一个鸸。

| | | hj*@hjp.at |

__ / | http://www.hjp.at/ | - Sam inFreefall

A "byte" in C-speak has been defined as the space occupied by a "char"
at least since C89.
In other contexts, a "byte" may be defined differently (e.g., as
"exactly 8 bits").

hp

--
_ | Peter J. Holzer | I know I''d be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hj*@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"


" Peter J. Holzer" < hj ********* @hjp.atwrites:
"Peter J. Holzer" <hj*********@hjp.atwrites:

2007-08-06 08:18,Richard< rg *** *@gmail.com写道:
On 2007-08-06 08:18, Richard <rg****@gmail.comwrote:

>现在char是一个字节吗?我失去了轨道。
>Is a char a byte now? I lose track.



A" byte"在C-speak中,至少自C89以来被定义为char

所占据的空间。

在其他情况下,字节表示字节。可以不同地定义(例如,作为
恰好8比特)。


A "byte" in C-speak has been defined as the space occupied by a "char"
at least since C89.
In other contexts, a "byte" may be defined differently (e.g., as
"exactly 8 bits").



所以一个字节是CHAR_BITS?哪个是99.999%的时间8位?

So A byte is CHAR_BITS? Which is in 99.999% of the time 8 bits?


这篇关于如何创建一个使用5Gb内存的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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