A
anandav2001
Hello developers,
I have created an executable(system tray application) in VS.net 2003
using VB.net. My app was taking 30 MB memory(since some web services
call are there which happens for each 10 sec checking internet is
available or not). Inorder to reduce huge memory consumption, what i
used is
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
Now i call FlushMemory on every 10 secs.
Now the memory consumption got reduced to 2 MB..But the problem is
after running this application for several days continously(say 1 week)
i got .net memory leak exception. I heard that .net memory exception
comes only if your application doesnot leave memory when other apps
need it. Can anyone guide me correctly...
Any help in this regard is greatly appreciated......
Regards,
Anand. A.V
I have created an executable(system tray application) in VS.net 2003
using VB.net. My app was taking 30 MB memory(since some web services
call are there which happens for each 10 sec checking internet is
available or not). Inorder to reduce huge memory consumption, what i
used is
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
Now i call FlushMemory on every 10 secs.
Now the memory consumption got reduced to 2 MB..But the problem is
after running this application for several days continously(say 1 week)
i got .net memory leak exception. I heard that .net memory exception
comes only if your application doesnot leave memory when other apps
need it. Can anyone guide me correctly...
Any help in this regard is greatly appreciated......
Regards,
Anand. A.V