views:

306

answers:

3

Hi

My application runs for few hours, There is no increase in any value ( vmsize, memory) of Task Manager. But after few hours i get out of memory errors.

In sysinternals i see that "Virtual Size" is contineously increasing, and when it reach around 2 GB i start getting memory errors.

So what kind of memory leak is that ? How can i demonstrate it with a code ? Is it possible to reproduce same thing with any piece of code where none of the memory value increase but only the Virtual Size in sysinternsl process explorer increase ?

thanks for any suggestions

+3  A: 

From the sound of things, you're running out of address space. 32-bit Windows splits the address space in half, one half for the user program and one half for the system, so each gets 2 Gigabytes.

The most common cause of this is fragmenting the memory space to the point that you can't find a chunk that's big enough for an allocation. Unfortunately, without knowing more about what you're doing, it's hard to guess why that might be happening though.

Jerry Coffin
+2  A: 

Virtual size is the number of pages that the process has allocated, those pages not currently in the working set (physically loaded in RAM) will be in the system's page file.

Typically you allocate memory that is not freed. This can be difficult to track down in the code without special tools like Rational Purify or Boundschecker for example. With sysinternals you see that there must be leak but it won't by no mean tell you where...

If your software is not so big you can try to log out the "new" and "delete" and see if there are too many objects in memory by managing lists of allocated objects (making your own memory debugger so to say). There are some helpers in the windows world like the CRT memory checking utils from Microsoft. They are useful in some cases.

jdehaan
+1  A: 

According to this thread on the sysinternals forum, Virtual size corresponds to the address space of the process (I'm guessing commited and reserved pages of memory)

Anders