avatar
请问delete的问题# Programming - 葵花宝典
s*t
1
c++里,如果一个程序new了很多object而不delete,那么当程序正常结束以后,系统会
不会把申请的内存收回呢?还是这个程序运行若干次以后,操作系统因为内存耗尽而瘫
痪?
谢谢!
avatar
T*9
2
会的

【在 s*******t 的大作中提到】
: c++里,如果一个程序new了很多object而不delete,那么当程序正常结束以后,系统会
: 不会把申请的内存收回呢?还是这个程序运行若干次以后,操作系统因为内存耗尽而瘫
: 痪?
: 谢谢!

avatar
s*t
3
是会回收,还是会crash?

【在 T*****9 的大作中提到】
: 会的
avatar
P*e
4
回收

【在 s*******t 的大作中提到】
: 是会回收,还是会crash?
avatar
n*d
5
Is there any way to check if the allocated memory is deleted? In other words
, how could we check memory leaking?

【在 P********e 的大作中提到】
: 回收
avatar
f*y
6
c++全靠自己小心了

words

【在 n**d 的大作中提到】
: Is there any way to check if the allocated memory is deleted? In other words
: , how could we check memory leaking?

avatar
h*g
7
好像有一些工具

words

【在 n**d 的大作中提到】
: Is there any way to check if the allocated memory is deleted? In other words
: , how could we check memory leaking?

avatar
k*f
8
If possible, you should use new in constructors and delete in desstructors.
So at the end of your program, all the allocated memory will be released.
If you use the right library, such as STL containers, and the right type of
smart pointers (look for them in boost.org or search "C++ TR1"), you seldom
need to use new and delete in your code. Then you don't have to worry about
memory leak caused by unmatched new and delete.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。