473,508 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.net memory leak problem in exe

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
1 1245
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3394
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
4770
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
20
8025
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
4509
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
22
9303
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.