Solved

Memory leak

Posted on 2008-09-29
7
262 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2013 debugging 2 35
Different Delete Messages 7 37
Access properties in nested observable collections 8 23
Angular - break the dataset in chunks? 7 39
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now