"定义"和“malloc”更多 [英] "define" and "malloc" more

查看:90
本文介绍了"定义"和“malloc”更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


事实上,我想让我的记忆耗尽。看看会发生什么。我的

系统是windowsXp。记忆是256M。我想我的cdes将比我拥有更多的内存

。代码如下:


#include< stdlib.h>

#include< stdio.h>


#define MAX 1000000000

int main(无效)

{

long double * temp =(long double *)malloc (MAX * sizeof(long double));

long double * temp1 =(long double *)malloc(MAX * sizeof(long double));

putchar(77 );

getchar();

getchar();


返回0;

}


但是在我的IDE中运行这些代码,我的系统中没有说错。那么

有人可以帮忙吗?

Hi all,

In fact, I want to let my memory run out. And see what will happen. My
system is windowsXp. Memory is 256M.I think my cdes will apply more memory
than I have. Codes are below:

#include <stdlib.h>
#include<stdio.h>

#define MAX 1000000000

int main(void)
{
long double *temp = (long double*)malloc (MAX * sizeof(long double));
long double *temp1 = (long double*)malloc (MAX * sizeof(long double));
putchar(77);
getchar();
getchar();

return 0;
}

But run these codes in my IDE, I do not say anything wrong in my system. So
could anyone help?

推荐答案

每个进程都会有4GB虚拟记忆。

其中2GB是Windows用户空间(其他2GB用于系统)


PS如果你有更多的请求,给我发一封电子邮件。

every process will have 4GB virturl memroy.
and 2GB of it is user space in Windows ( other 2GB is for system )

P.S. send me an email if you have more queesion(s).


似乎不仅仅是因为美德记忆。

我查了一下我的Windows任务管理器在运行代码时。使用PF

没有任何变化。

我预计PF的使用量会增加。


" monnand" < mo ***** @ gmail.com>

??????:11 ********************* *@i3g2000cwc.googleg roups.com ...
Seems not only because of virtural memoral.
I checked my "windows task manager" while running the code. The usage of PF
do not have any changes.
I expect an increased usage of PF.

"monnand" <mo*****@gmail.com>
??????:11**********************@i3g2000cwc.googleg roups.com...

每个进程都有4GB virturl memroy。

和2GB是用户空间在Windows中(其他2GB用于系统)


PS如果您有更多的请求,请给我发送电子邮件。
every process will have 4GB virturl memroy.
and 2GB of it is user space in Windows ( other 2GB is for system )

P.S. send me an email if you have more queesion(s).



陈树生schrieb:
Chen Shusheng schrieb:

大家好,


事实上,我想让我的记忆耗尽。看看会发生什么。我的

系统是windowsXp。记忆是256M。我想我的cdes将比我拥有更多的内存

。代码如下:


#include< stdlib.h>

#include< stdio.h>


#define MAX 1000000000

int main(无效)

{

long double * temp =(long double *)malloc (MAX * sizeof(long double));

long double * temp1 =(long double *)malloc(MAX * sizeof(long double));
Hi all,

In fact, I want to let my memory run out. And see what will happen. My
system is windowsXp. Memory is 256M.I think my cdes will apply more memory
than I have. Codes are below:

#include <stdlib.h>
#include<stdio.h>

#define MAX 1000000000

int main(void)
{
long double *temp = (long double*)malloc (MAX * sizeof(long double));
long double *temp1 = (long double*)malloc (MAX * sizeof(long double));



请一位发短信的人写下10万次:


我不会投出malloc'的返回值更多,


完成后,写入1000000000次:


"我将每次检查malloc'的返回值为NULL ;。

Take a texteditor and write 1000000000 times:

"I won''t cast malloc''s return value any more",

when done, write 1000000000 times:

"I will check malloc''s return value for NULL every time".


putchar(77);

getchar();

getchar();


返回0;

}


但是在我的IDE中运行这些代码,我的系统中没有说错。那么

有人可以帮忙吗?
putchar(77);
getchar();
getchar();

return 0;
}

But run these codes in my IDE, I do not say anything wrong in my system. So
could anyone help?



我猜,malloc()返回NULL并且根本没有分配内存。


-

Thomas

I guess, malloc() returned NULL and there was no memory allocated at all.

--
Thomas


这篇关于&QUOT;定义&QUOT;和“malloc”更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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