|
-
Jan 19th, 2005, 01:25 AM
#1
Thread Starter
Hyperactive Member
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!
"I'm Brian and so is my Wife"
-
Jan 19th, 2005, 05:09 AM
#2
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
"The dark side clouds everything. Impossible to see the future is."
-
Jan 19th, 2005, 05:28 AM
#3
Thread Starter
Hyperactive Member
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.
"I'm Brian and so is my Wife"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|