Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Memory leak

Posted on 2008-09-29
7
Medium Priority
?
280 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
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.

 
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 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