Pagefile Control (Virtual Memory)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like some assistance on a application I am developing in vb.net 2003
that uses a large dataset to query a database. Most queires are small, and
execute with no problem. When a large query is executed and stored in the
dataset, I use the garbage collector and the setProcessWorkingSetSize()
function to remove the data from memory when it is no longer needed. This
works great for the RAM, but as far as the pagefile, it grows for every large
query and is not released untill program shutdown.

Thanks in advance.
 
Laurent,

One of the most important things from managed code is to manage the
efficient use of memory.

I know that a lot of people don't want to do what the manager tells.

However mostly it is better for the final result to do it that way and
follow up the directions for that, than do it in a complete opposite way.

Just my thought,

Cor
 
The call to setProcessWorkingSet simply sets the targets for the amount of
RAM allocated to your process. It doesn't affect the amount of committed VM
that you have - that's what requires page file space. When the GC runs it
compacts the managed heap(s), but may not return allocated VM to the OS. I
don't know what it's policy is, but it has dynamically adjusted quotas for
the heap generations that I would guess determine the amount of VM it keeps
allocated. I would hope that if the program ran for some with a much smaller
memory demand, that some of that VM would be returned as the GC adjusted the
quotas.

I'm not aware of any way of controling this behaviour. Generally it's best
to leave the memory management systems to figure it out for themselves.

If the pagefile usage grows each time you run your large query, that smells
like a memory leak. Have you checked the heap memory usage after each call
to GC.Collect()?
 
Back
Top