0
It seems to work very well. I hope there will to no side affects from this. Thanks a lot.
0
Hi saphiroth,
Actually i also had the same problem. My project is heavier, having more than 110 forms. I also in search of a solution for more than 1 month. i have tried various methods but in vain.
At last i tried this mtd and i haven't experienced any performance degrade by using this method. Try out and tell if u face any problem.
Chk out this url for more info
http://addressof.com/blog/archive/2003/11/19/281.aspx
0
Again I want to say thanks. How did u find this method? Is it safe to use through out every form?
What I did is make a new class and put that function in the class. So I create an instance of the class and call this function to clear out RAM. I hope this is ok to do.
0
nevermind, I read up on the SetProcessWorkingSetSize. Thank you for your help.
0
I don't clearly understand what this does or how it works. How does it help memory management?
0
Have you tried using the SetProcessWorkingSetSize Win32 API Function
Form1.vb
Private Sub Buttonopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2()
frm2.MdiParent = Me
frm2.Dock = DockStyle.Fill
frm2.Show()
frm2.BringToFront()
End Sub
Form2.vb
Private Declare 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
'Form Close
Private Sub Buttonclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
SaveMemory()
Me.Close()
End Sub
0
Not necessarily. Garbage collection occurs when an object tries to allocate memory for a new object and the heap has no free memory. So memory allocated may not be collected if the apllication doesn't create many objects. Further, it can take up to two collection cycles before an object's memory allocation is actually released back to the pool. When memory is collected the object's Finalize method is called, and then the collector frees the memory.
If you need to get memory back to the heap faster you can call GC.Collect yourself. If you do so, you should follow it up with a GC.WaitForPendingFinalizers call. There is a slight performance hit in doing this.