Your VB .NET App taking up too much memory??
Use this to clean it up....very,very useful.
VB Code:
Public Class MemoryManagement
Private Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" ( _
ByVal process As IntPtr, _
ByVal minimumWorkingSetSize As Integer, _
ByVal maximumWorkingSetSize As Integer) As Integer
Public Shared Sub FlushMemory()
GC.Collect()
GC.WaitForPendingFinalizers()
If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)
End If
End Sub
End Class
I found the above on the net because my DataGrid driven application was simply taking up too much memory on the client pc's.
I put this class into my project and call the FlushMemory function after each time a user fills a DataSet....my apps memory usage went from 30,000KB to less than 5,000KB!
Re: Your VB .NET App taking up too much memory??
Hi
Calling SetProcessWorkingSetSize will force part of the memory used by the application will be written to disk, so performance will be affected.
Regards
Jorge
Re: Your VB .NET App taking up too much memory??
Hello!
I didn't know that.
However, the app that I'm writing, the users of it will have it open all day (and it dynamically updates data), so I needed to get around the problem of running out of virtual memory and this solution seems to work for me (they'll just run out of disk space now instead! :) )
Maybe I'm just not freeing up my resources properly.