Memory usage problems

G

Gene

I have a program with a couple datasets and a minimum number of controls.
The main form is a MDI container. The problem is that when the program
loads the memory in the working set shows 49 MB. If I minimize the
application and then restore it the usage drops to 9 or 10 MB. I have tried
everything to get the same result without ticking off a user by minimizing
and restoring evertime something happens in the application. What am I
missing? What does the program do when it's minimized that I can replicate
in code without minimizing?

Any help is appreciated.
 
C

Cor Ligthert

Gene,

What you describe seems to me the wished behaviour from the managed code. It
frees memory when it is needed or when there is idle time and it let it stay
when there is enough memory. Result is that the processing goes on and the
computer is not spending time with useless cleaning.

However when you have real memory leaking. (It is never set to lower) than
you can look to this what Rich was feeding back to the newsgroup last week.

Before his investigation I had never heard of that problem.

http://www.google.com/[email protected]

I hope this helps?

Cor
 
G

Gene

Thanks for the link. I found a few other mentions on the subject as well.
I found some code (VB) to reduce the Working Set to a minimum number as is
done when the app is minimized. I'm not real comfortable with it since this
writes out to the hard drive virtual mem to clear the memory but may put it
in as a flagged function if the WS reaches a large number during runtime.
Code:

Private Declare Auto Function SetProcessWorkingSetSize Lib "kernel32.dll"
(ByVal hProcess As IntPtr, _
ByVal dwMinimumWorkingSetSize As Int32,ByVal dwMaximumWorkingSetSize As
Int32) As Int32

Public Function SaveMemory() As Int32
Return _

SetProcessWorkingSetSize(Diagnostics.Process.GetCurrentProcess.Handle, -1, -
1)
End Function
End Function

Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top