问题
I have an application that uses a 3rd party API and I think they are having a memory leak issue. 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.
I don't have any memory leak behavior if I comment out the VMI vmi; under my VMITest class. With my limited knowledge in C++ I assume this is because the virtual VMI class does not have the virtual destructor.
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.
If I run my test program, it automatically jumped by roughly 2 Gigs and stays there (the first white circle area). 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. 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
}
回答1:
On windows 32 bit applications by default have an address space of 2GB even on a 64 bit windows OS. 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.
回答2:
The memory usage limit depends on your application and the platform, check this MSDN article for details.
I think you need a memory leak dectect tool for your application, DebugDiag is a good choice on Windows and it's free.
来源:https://stackoverflow.com/questions/19911298/memory-leak-does-window-have-a-safeguard-to-prevent-max-memory-reached