由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 请问delete的问题
相关主题
why do we still use dynamic allocation?one question about overloading operator delete
请教一下,exception时,destructor一定会被调用么?回答C++的弱问题
一个小问题[合集] C++的弱问题
1999年出版的C,C++,Java语言教程过期了吗??一个 default constructor 的问题
pointer to base class = new derived, what will happend??What does the default constructor do?
请教关于allocator member function 的问题不用STL, C++里怎么realloc?
什么是OS Memory management and heap structure?typedef basic_string string;
new and delete in c++C++ 自学练习
相关话题的讨论汇总
话题: delete话题: memory话题: c++话题: new话题: allocated
进入Programming版参与讨论
1 (共1页)
s*******t
发帖数: 2896
1
c++里,如果一个程序new了很多object而不delete,那么当程序正常结束以后,系统会
不会把申请的内存收回呢?还是这个程序运行若干次以后,操作系统因为内存耗尽而瘫
痪?
谢谢!
T*****9
发帖数: 2484
2
会的

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

s*******t
发帖数: 2896
3
是会回收,还是会crash?

【在 T*****9 的大作中提到】
: 会的
P********e
发帖数: 2610
4
回收

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

【在 P********e 的大作中提到】
: 回收
f*******y
发帖数: 988
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?

h********g
发帖数: 116
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?

k**f
发帖数: 372
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.
1 (共1页)
进入Programming版参与讨论
相关主题
C++ 自学练习pointer to base class = new derived, what will happend??
在 windows下的C++开发平台是不是 Dev-C++?请教关于allocator member function 的问题
C++ STL 的问题什么是OS Memory management and heap structure?
C++ Segment Faultnew and delete in c++
why do we still use dynamic allocation?one question about overloading operator delete
请教一下,exception时,destructor一定会被调用么?回答C++的弱问题
一个小问题[合集] C++的弱问题
1999年出版的C,C++,Java语言教程过期了吗??一个 default constructor 的问题
相关话题的讨论汇总
话题: delete话题: memory话题: c++话题: new话题: allocated