Link to home
Start Free TrialLog in
Avatar of mhouldridge
mhouldridge

asked on

Memory leak

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?
Avatar of silemone
silemone
Flag of United States of America image

Actually, you should consider not only setting them to null, but also disposing of them whenever possible
Avatar of angus_young_acdc
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.
Avatar of mhouldridge
mhouldridge

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of angus_young_acdc
angus_young_acdc
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if your integers are not nullabe, then you can only set them to 0...null is only for objects...
as angus has shown, making integer type nullable or any primative, you must add a ? behind it...
Hi,

Thanks for the info guys...