Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
GeneralRe: setting install location for merge module Pin
godzooky6-Feb-04 4:37
godzooky6-Feb-04 4:37 
GeneralRe: setting install location for merge module Pin
Douglas Troy6-Feb-04 6:09
Douglas Troy6-Feb-04 6:09 
GeneralRecommended Book Pin
pn19956-Feb-04 3:41
pn19956-Feb-04 3:41 
GeneralRe: Recommended Book Pin
Douglas Troy6-Feb-04 4:11
Douglas Troy6-Feb-04 4:11 
GeneralRe: Recommended Book Pin
Charlie Williams6-Feb-04 5:45
Charlie Williams6-Feb-04 5:45 
GeneralControlling generation of interface stubs Pin
Robert Matheson6-Feb-04 1:32
Robert Matheson6-Feb-04 1:32 
Generaldestructor and dispose Pin
GetOn&GetGoing6-Feb-04 1:08
GetOn&GetGoing6-Feb-04 1:08 
GeneralRe: destructor and dispose Pin
Colin Angus Mackay6-Feb-04 2:17
Colin Angus Mackay6-Feb-04 2:17 
The short answer is that when you set Object=nothing (or Object=null in C#) nothing happens until the garbage collector runs. When the garbage collector runs is non-determinisitic which means that it can't really be predicted.

For more details the following from MSDN should help.

MSDN wrote:
During a collection, the garbage collector will not free an object if it finds one or more references to the object in managed code. However, the garbage collector does not recognize references to an object from unmanaged code, and might free objects that are being used exclusively in unmanaged code unless explicitly prevented from doing so. The KeepAlive method provides a mechanism that prevents the garbage collector from collecting objects that are still in use in unmanaged code.

Other than managed memory allocations, implementations of the garbage collector do not maintain information about resources held by an object, such as file handles or database connections. When a type uses unmanaged resources that must be released before instances of the type are reclaimed, the type can implement a finalizer.

In most cases, finalizers are implemented by overriding the Object.Finalize method; however, types written in C# or C++ implement destructors, which compilers turn into an override of Object.Finalize. In most cases, if an object has a finalizer, the garbage collector calls it prior to freeing the object. However, the garbage collector is not required to call finalizers in all situations. Also, the garbage collector is not required to use a specific thread to finalize objects, or guarantee the order in which finalizers are called for objects that reference each other but are otherwise available for garbage collection.

In scenarios where resources must be released at a specific time, classes can implement the IDisposable interface, which contains the IDisposable.Dispose method that performs resource management and cleanup tasks. Classes that implement Dispose must specify, as part of their class contract, if and when class consumers call the method to clean up the object. The garbage collector does not, by default, call the Dispose method; however, implementations of the Dispose method can call methods in the GC class to customize the finalization behavior of the garbage collector.


--Colin Mackay--

EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar


GeneralC# Program Pin
SatyaDY5-Feb-04 23:00
SatyaDY5-Feb-04 23:00 
GeneralRe: C# Program Pin
Heath Stewart6-Feb-04 2:49
protectorHeath Stewart6-Feb-04 2:49 
QuestionCreate .dll's in VS.NET? Pin
Morten Kristensen5-Feb-04 22:29
Morten Kristensen5-Feb-04 22:29 
AnswerRe: Create .dll's in VS.NET? Pin
Mazdak5-Feb-04 22:54
Mazdak5-Feb-04 22:54 
QuestionHow to minimize a program in C#? Pin
Serdar YILMAZ5-Feb-04 21:55
Serdar YILMAZ5-Feb-04 21:55 
AnswerRe: How to minimize a program in C#? Pin
Morten Kristensen5-Feb-04 22:18
Morten Kristensen5-Feb-04 22:18 
AnswerRe: How to minimize a program in C#? Pin
Mazdak5-Feb-04 22:28
Mazdak5-Feb-04 22:28 
GeneralType of control object... Pin
Weiye Chen5-Feb-04 21:54
Weiye Chen5-Feb-04 21:54 
GeneralRe: Type of control object... Pin
thomasa5-Feb-04 22:56
thomasa5-Feb-04 22:56 
GeneralRe: Type of control object... Pin
Dan_P5-Feb-04 23:31
Dan_P5-Feb-04 23:31 
GeneralRe: Type of control object... Pin
Weiye Chen6-Feb-04 1:11
Weiye Chen6-Feb-04 1:11 
GeneralRe: Type of control object... Pin
Weiye Chen6-Feb-04 1:07
Weiye Chen6-Feb-04 1:07 
GeneralCrystal reports with multi typed datasets Pin
SimonS5-Feb-04 21:03
SimonS5-Feb-04 21:03 
GeneralRe: Crystal reports with multi typed datasets Pin
SimonS5-Feb-04 21:28
SimonS5-Feb-04 21:28 
GeneralRe: Crystal reports with multi typed datasets Pin
Heath Stewart6-Feb-04 2:44
protectorHeath Stewart6-Feb-04 2:44 
QuestionHow to create a fadein dialog by C#? Pin
tuliplanetrain5-Feb-04 20:59
tuliplanetrain5-Feb-04 20:59 
AnswerRe: How to create a fadein dialog by C#? Pin
Mazdak5-Feb-04 21:27
Mazdak5-Feb-04 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.