且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除所有

更新时间:2023-12-05 17:20:28


bo *@coolgroups.com skrev:

bo*@coolgroups.com skrev:
为什么c ++中没有deleteall关键字
这不会解决很多内存泄漏问题吗?
why can''t there be a deleteall keyword in c++ that
deletes all the memory previously allocated by
the new keyword?

wouldn''t this solve a lot of memory leak issues?


>
不 - 你为什么这么认为?所有分配的内存都会无效

突然之间没有任何选择,只能终止

程序(通常会释放所有资源)。


/ Peter



No - why do you believe so? All memory allocated would be invalid
suddenly and there would not really be any option but to terminate the
program (which typically releases all resources anyway).

/Peter


通常在终止之前调用它。我不认为

终止通常会释放所有资源。

it would be called before termination usually. i don''t think
termination typically releases all resources.



bo *@coolgroups.com 写道:
它通常在终止之前被调用。我不认为
终止通常会释放所有资源。
it would be called before termination usually. i don''t think
termination typically releases all resources.




deleteall没有意义,因为它无法控制其行为

本身。

现代操作系统的'内存管理可以在终止进程后处理内存资源的释放

。当进程运行时,内存泄漏是致命的,因此程序员应该避免内存泄漏。



deleteall doesn''t make sense because it doesn''t control its behaviors
itself.
Modern OS'' memory management can handle the release of memory resource
after terminating a process. Memory leakage is fatal while the process
is running so the programmer should avoid the memory leakage.