另一个内存泄漏问题 [英] Another memory leak question

查看:73
本文介绍了另一个内存泄漏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序持续运行4到6个小时,在此期间,内存或类似内容没有持续增加.

My application keeps running for 4 to 6 hours, During this time there is no contineous increase in memory or anything similar.

然后4到6个小时后,我开始收到EOutofMemory异常.即使在那时,每个任务管理器也只使用了3GB RAM中的900MB.而且应用程序本身使用的内存不超过200MB.

Then after 4 to 6 hours i start getting EOutofMemory Exceptions. Even still at that time there is only 900MB out of 3GB RAM is used as per task manager. And application itself is not using more then 200MB .

那为什么我会收到EOoutofMmory错误?

Then why i am getting EOoutofMEmory error ?

这是否意味着内存泄漏不一定在任务管理器中可见?

Does it mean that memory leak is not necessarily visible in task manager ?

晚饭

推荐答案

使用Process Explorer而不是Task Manager查看应用程序的内存消耗.

Use Process Explorer instead of Task Manager to look at the memory consumption of your application.

  • 专用字节:是您的应用程序使用的内存量.这也是任务管理器在"VM Size"列中(在XP下)显示的值
  • 虚拟内存大小:这是您的应用程序当前正在使用的最大地址.此值受2 GB限制(对于32位OS中的32位应用程序).

专用字节和虚拟内存大小之间的差异是由内存碎片引起的.您唯一可以做的就是使用一个内存管理器来尝试减少碎片,例如通过使用内存池.

The different between Private Bytes and Virtual Memory Size is caused by memory fragmentation. The only thing you can do about it is to use a memory manager that tries to reduce fragmentation, e.g. by using memory pools.

DougLea内存管理器是免费的替代品.也有商业内存管理器.您也可以尝试编写自己的内存管理器(这并不难:您只需覆盖new和delete运算符即可.)

The DougLea memory manager is a free alternative. There are also commercial memory manager. You can also try to write your own memory manager (it's not that hard: you only have to override the new and delete operators).

还有一些技巧可以增加2 GB的限制.如果您使用/LARGEADDRESSAWARE标志链接应用程序,则您的应用程序将能够分配3GB内存(如果XP使用/3GB标志引导XP,则对于Vista/W7可能会有类似的标志,但我不知道).在64位操作系统上,LargeAddressAware可执行文件甚至可以使用多达4 GB的内存.

There are also tricks to increase the limit of 2 GB. If you link your application with the /LARGEADDRESSAWARE flag, your application will be able to allocate 3GB of memory (if XP is booted with the /3GB flag, for Vista/W7 there's probably a similar flag but I don't know this). On 64-bit Operating systems, a LargeAddressAware executable can even use up to 4 GB of memory.

这篇关于另一个内存泄漏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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