By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,651 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,651 IT Pros & Developers. It's quick & easy.

.net memory leak problem in exe

P: n/a
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

Dec 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
SetProcessWorkingSetSize does not solve your memory consumption. It only
trims the part of memory that process' once occupied.
You don't need the SetProcessWorkingSetSize at all.

You are probably watching the "Memory Usage" column in task manager. You
should be watching "VM size" column, which is hidden by default. This is
your application's allocated private bytes (total amount of memory allocated
by the process).

You need to make sure you dispose every object you create. If the object
doesn't implement a Dispose method, you should make sure that all references
to the object are lost (every time you associate a variable with the object,
reference is added and you need to set those variables to Nothing).
<an*********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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

Dec 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.