?
Solved

Memory leak

Posted on 2008-09-29
7
Medium Priority
?
282 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 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