简体   繁体   English

内存泄漏,窗口是否有安全措施以防止达到最大内存?

[英]Memory leak, does window have a safeguard to prevent max memory reached?

I have an application that uses a 3rd party API and I think they are having a memory leak issue. 我有一个使用第三方API的应用程序,我认为他们有内存泄漏问题。 I wrote a small test program (below) to test this out, please note, both VMIListener and VMI are from the APIs in which I'm implementing their virtual interface methods. 我写了一个小测试程序(下面)来测试它,请注意,VMIListener和VMI都来自我正在实现其虚拟接口方法的API。

I don't have any memory leak behavior if I comment out the VMI vmi; 如果我注释掉VMI vmi,我没有任何内存泄漏行为; under my VMITest class. 在我的VMITest类下。 With my limited knowledge in C++ I assume this is because the virtual VMI class does not have the virtual destructor. 由于我对C ++的了解有限,我认为这是因为虚拟VMI类没有虚拟析构函数。

However, my question is does window have some safeguard in place for maxing out memory from memory leak? 但是,我的问题是窗口是否有一些保护措施可以最大限度地减少内存泄漏的内存? because I see an interesting result within the Window task Manager. 因为我在Window任务管理器中看到了一个有趣的结果。

If I run my test program, it automatically jumped by roughly 2 Gigs and stays there (the first white circle area). 如果我运行我的测试程序,它会自动跳过大约2个Gigs并停留在那里(第一个白色圆圈区域)。 If I run my actual application (2nd white area), the leak slowly reach up to about the same level (5.8 Gig) and in both case they stop there without further increase in the memory. 如果我运行我的实际应用程序(第二个白色区域),泄漏会慢慢达到大约相同的水平(5.8 Gig),并且在两种情况下它们都会停在那里而不会进一步增加内存。 I run several other tests where I let my application running, the leak stops when they reach this specific level of memory usage. 我运行了几个其他测试,我让我的应用程序运行,泄漏在达到特定内存使用级别时停止。

记忆指标

void main(int cArgs, char* saArgs[])
{
     VMITest    *m_pVMI;

     while(true)
     {
         m_pVMI = new VMITest();
         delete m_pVMI;
         m_pVMI = NULL;
     }
 }


 class VMITest : public VMIListener
 {

    public:
           VMI  vmi;
           VMITest();

    // VMIListener interface methods.
 };

 class VMI_API VMI
 {
   public:
         VMI();
   //some more functions
 }

The memory usage limit depends on your application and the platform, check this MSDN article for details. 内存使用限制取决于您的应用程序和平台,请查看此MSDN文章以获取详细信息。

I think you need a memory leak dectect tool for your application, DebugDiag is a good choice on Windows and it's free. 我认为你的应用程序需要一个内存泄漏检测工具, DebugDiag在Windows上是一个不错的选择,它是免费的。

On windows 32 bit applications by default have an address space of 2GB even on a 64 bit windows OS. 在Windows 32位应用程序默认情况下,即使在64位Windows操作系统上也有2GB的地址空间。 Allocation of memory more than your address space will fail. 内存分配超过地址空间将失败。

It is possible to use the /LARGEADDRESSAWARE linker option to extend this limit to 3GB on 32bit windows or 4GB on 64 bit windows. 可以使用/ LARGEADDRESSAWARE链接器选项将此限制扩展到32位窗口上的3GB或64位窗口上的4GB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM