堆内存实际上什么时候释放? [英] When does the heap memory actually get released?

查看:328
本文介绍了堆内存实际上什么时候释放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用new as分配内存,当我在自己的方法之一和析构函数中接收数据时,我将使用delete释放所有分配的内存.

I'm allocating memory using new as and when I receive data in one of my methods and in the destructor, I'm releasing all the allocated memory using delete.

但是,从任务管理器释放内存后,当我在进程"选项卡下查看内存使用情况时,内存使用情况仍然保持不变.不会给人以内存被释放的印象.

However, after releasing the memory, from the task manager, when I look at mem usage under the process tab, the memory usage still remains the same. It doesn't give an impression that the memory is being released.

那么,什么时候才真正释放内存?找出进程正在使用的实际内存的最佳方法是什么.

So, when does the memory actually get released? And what is the best way to find out the actual memory being used by a process.

谢谢

推荐答案

在大多数情况下,应用程序运行时永远不会将其交还给操作系统.然后,当然,所有资源都将由操作系统恢复.

In most cases, it's never given back to the OS while the app is running. Afterwards, of course, all resources are recovered by the OS.

[在正确地指出从不"很长一段时间后编辑,……"

这篇关于堆内存实际上什么时候释放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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