记忆相关 [英] memeory related

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

问题描述

我已动态分配内存,而我根本不使用delete []。现在

假设我的应用程序需要更多内存。我再次分配

而不使用delete []。

最终会发生什么?任何人都可以帮忙。


Thanx

I have allocated memory dynamically and I am not at all using delete[]. Now
suppose my application is demanding for more memory. And I allocate it again
without using delete[].
What all can happen eventually? Can anyone help.

Thanx

推荐答案

如果对std :: bad_alloc的异常处理不是围绕内存完成

分配声明,然后应用程序将耗尽内存

分配给它并将被异常终止操作

系统;否则会引发std :: bad_alloc异常。

If exception handling for std::bad_alloc isn''t done around the memory
allocation statement, then the application would run out of memory
allocated to it and would be abnormally terminated by the Operation
System; else std::bad_alloc exception would be thrown.


对不起输入错误Operation!请将其读作正在运行。


谢谢!


frame写道:
Sorry for the typo "Operation"! Please read it as "Operating".

Thanks!

frame wrote:

如果std :: bad_alloc的异常处理没有围绕内存

分配语句进行,那么应用程序会耗尽内存

分配给它并且将被操作

系统异常终止;否则会抛出std :: bad_alloc异常。
If exception handling for std::bad_alloc isn''t done around the memory
allocation statement, then the application would run out of memory
allocated to it and would be abnormally terminated by the Operation
System; else std::bad_alloc exception would be thrown.


" subrat" < su *********** @ in.bosch.com写信息

news:el ********** @ news4.fe.internet。 bosch.com ...
"subrat" <su***********@in.bosch.comwrote in message
news:el**********@news4.fe.internet.bosch.com...

>我已动态分配内存,而我根本不使用delete []。现在

假设我的应用程序需要更多内存。并且我再次分配



而不使用delete []。

最终会发生什么?任何人都可以帮忙。


Thanx
>I have allocated memory dynamically and I am not at all using delete[]. Now
suppose my application is demanding for more memory. And I allocate it
again
without using delete[].
What all can happen eventually? Can anyone help.

Thanx



只需运行这个程序,你就会看到。运行后你可能想要
重新启动计算机。


int main()

{

int * p;

while(true)

{

p = new int [10000];

}

}


将会发生内存不足的情况。由于内存是新的并且没有被删除,因此它永远不会被释放回程序(或操作系统)所以

最终你会耗尽内存。

Just run this program and you''ll see. After you run it you might want to
reboot your computer.

int main()
{
int* p;
while (true)
{
p = new int[10000];
}
}

What will happen is that you will run out of memory. Since the memory is
newed and not deleted it''s never released back to the program (or the OS) so
eventually you''ll run out of memory.


这篇关于记忆相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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