how to mark an object for garbage collection ??
Tech-Archive recommends: Fix windows errors by optimizing your registry
Hi,
how do you mark an object for garbage collection in C++.NET 2005 ?
MyDbClass^ obj = gcnew MyDbClass();
// Release the object
obj = 0; --> COMPILER ERROR
obj = nullptr; // nope : this does not mark it for garbage
// collection (see help)
so ... how ?
thanks
Chris
**********************************************************************
Sent via Fuzzy Software @
http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
.
Relevant Pages
- Re: how to mark an object for garbage collection ??
... > MyDbClass^ obj = gcnew MyDbClass(); ... You do not "mark objects for garbage collection". ... MyDbClass obj(); ... (microsoft.public.dotnet.languages.vc) - Re: object = nothing?
... Dim obj as New MyObject ... the Garbage Collection process handle this for me. ... Note that COM used reference counting to detect whether or not an object ... necessary to clear all references to an object to be able to destroy it. ... (microsoft.public.dotnet.languages.vb) - Re: how to mark an object for garbage collection ??
... called when it leaves the scope, ... > referencing them and the GC ... > MyDbClass obj(); ... > obj = gcnew MyDbClass; ... (microsoft.public.dotnet.languages.vc) - Re: object = nothing?
... If you skip the assignment to Nothing, they will still be marked for gargabe collection once they go out of scope and there are no other references to the objects. ... This guarantees that any acquired resources are released before garbage collection. ... Dim obj as New MyObject ... should let the Garbage Collection process handle this for me. ... (microsoft.public.dotnet.languages.vb) - Garbage collection and new keyword in parameters
... I'm trying to better understand the behanviour of garbage collection ... private void MyMethod(MyObj obj) ... private void OtherMethod() ... (microsoft.public.dotnet.languages.csharp) |
|