Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mem Usage keeps going up 1

Status
Not open for further replies.

RMasters

Programmer
Nov 14, 2000
36
0
0
GB
I am having trouble with an application that I have just completed, when using it I noticed that my machine slows down alot. Investigation reveals that when I dispose of forms, the memory is not being freed up. I set-up a thread to run "gargage collection" every few seconds but the problem remains. How can I rectify this.

Kind regards

Rick
 
You likely have a memory leak. It's harder to do in .NET, but it's still possible.

What you want to write is "sandwich" code, where you allocate an object, use it (or pass it somewhere else to be used), and then free it by setting it to Nothing. The idea is not to have orphaned references.

You shouldn't do this (set stuff to Nothing) for value types (int, enumerations, DateTime, etc.) For most reference types (classes, strings, interfaces) you don't need to do this, but you can. You absolutely should do this when the object contains an unmanaged resource, like a DB connection, file, socket, etc.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top