Question Free memory of .net objects

suresh_ed

Active member
Joined
May 19, 2008
Messages
27
Programming Experience
1-3
Am using lots of .Net and Indesign Objects in my StandAlone APplicataion.

My Application is crashing because of memory usage [Memory allocation and deallocation].

Will it deallocate if i use the following for the object:
VB.NET:
Object=nothing

Please suggest how to free memory of .net and Indesign objects and for which i will have to free memory.
 
suresh_ed said:
Will it deallocate if i use the following for the object:
VB.NET:
Object=nothing
Deallocate the variable reference, yes. Free memory, perhaps/usually not right away, and in some cases some resources will not free if you do this.
send2te said:
You need to read documentation of "garbage collection in .net" and try to implement this.
Agree, here are some relevant help topic links:
Object Lifetime: How Objects Are Created and Destroyed
Garbage Collection
Automatic Memory Management

In short, you need to call Dispose method if object expose this, sometimes a Close can be used instead. Using Statement (Visual Basic) is a simplification that is useful sometimes.

When writing your own classes you have to decide if implementing IDisposable is necessary to free memory usage/resources, this will expose the Dispose method for consumers of your class. The ideas are the same as with local memory consumption, close/dispose where necessary, dereference variables with long lifetime, clear large fields/collections, etc.
 
Actually what is happening in my system the CPU Usage is going more than 100% sometimes and that time it is crashing.
Please suggest why it is happening.
 
Back
Top