本文介绍了当程序用x关闭时,内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是一个愚蠢的问题,但如果我创建一个控制台应用程序动态创建对象等,我确保在关机时释放memmory。如果用户使用窗口上的x按钮关闭应用程序,会发生什么?将会有记忆漏洞,如果是,我如何防止它?

Might be a stupid question, but if I create a console-application that dynamicly creates object and such, I make sure to free the memmory at shutdown. What happens if a user closes the application with the "x" button on the window? will there be memoryleaks and if so, how do i prevent it?

推荐答案

不,不会有任何内存泄漏。

No, there won't be any memory leaks.

当用户关闭应用程序时,应用程序运行的过程将终止。一旦某个进程终止,操作系统(OS)只需回收它所拥有的所有内存分配给进程。

When a user closes your application the process in which your appication runs gets terminated.Once a process gets terminated, the Operating System(OS) simply reclaims all the memory it had allocated to the process.

请注意,对于操作系统,内存是否被应用程序泄漏并不重要,或者它只是回收它分配给进程的内容。

Note that for an OS there is no importance whether memory was leaked by the application or not it is simply reclaiming what it allocated to the process.

这篇关于当程序用x关闭时,内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 17:31
查看更多