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?
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?
Actually, you should consider not only setting them to null, but also disposing of them whenever possible
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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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...
ASKER
Hi,
Thanks for the info guys...
Thanks for the info guys...