Solved

Memory leak

Posted on 2008-09-29
7
275 Views
Last Modified: 2010-04-15
Experts,

I've developed a service which works fine, however I've noticed the memory usage for the application (whilst there are no processes taking place) incrememt slowly, by about 6k every seven seconds.

I'm concerned that this may cause problems in the long term, and I'd like to find out what could be causing this.  

Should I consider setting the variables to null after the program cycle (while true loop) has completed?
0
Comment
Question by:mhouldridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 21

Expert Comment

by:silemone
ID: 22596574
Actually, you should consider not only setting them to null, but also disposing of them whenever possible
0
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 22596598
Yes where possible if you're not using something you should dispose it.  Certain things don't look like they would cause a problem but if you have a constantly running loop, and objects are being used and then not disposed of, they will simply all be "dumped" into a big pile, and then after the next loop that lot will go in the "pile", and so on.  Basically adding up to a lot of cost and wasted memory.
0
 

Author Comment

by:mhouldridge
ID: 22596678
Hi,

Thanks for the info.  I get problems with integers, attempting to set to null....

With Cannot convert to null error.

Is there a generic method for settings variables of any type to null.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 500 total points
ID: 22596836
There certainly is, here is an example:
int? myIntger = 3;  // Declare the integer with a ? to state that its nullable

myIntger = null; // Then you can just set it to null when necessary
0
 
LVL 21

Expert Comment

by:silemone
ID: 22596851
if your integers are not nullabe, then you can only set them to 0...null is only for objects...
0
 
LVL 21

Expert Comment

by:silemone
ID: 22596870
as angus has shown, making integer type nullable or any primative, you must add a ? behind it...
0
 

Author Comment

by:mhouldridge
ID: 22596899
Hi,

Thanks for the info guys...

0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question