Click here to Skip to main content
15,889,335 members
Home / Discussions / C#
   

C#

 
GeneralRe: conditional operator (?:) performance Pin
Anonymous27-Apr-04 2:49
Anonymous27-Apr-04 2:49 
GeneralDataGrid row: RowState unchange problem Pin
Chris#26-Apr-04 10:47
Chris#26-Apr-04 10:47 
GeneralRe: DataGrid row: RowState unchange problem Pin
Heath Stewart26-Apr-04 11:50
protectorHeath Stewart26-Apr-04 11:50 
GeneralRe: DataGrid row: RowState unchange problem Pin
Chris#27-Apr-04 4:49
Chris#27-Apr-04 4:49 
GeneralGarbage collector Pin
Ruchi Gupta26-Apr-04 10:39
Ruchi Gupta26-Apr-04 10:39 
GeneralRe: Garbage collector Pin
SJ_Phoenix26-Apr-04 19:16
SJ_Phoenix26-Apr-04 19:16 
GeneralRe: Garbage collector Pin
Stefan Troschuetz26-Apr-04 20:40
Stefan Troschuetz26-Apr-04 20:40 
GeneralRe: Garbage collector Pin
Mike Dimmick27-Apr-04 0:04
Mike Dimmick27-Apr-04 0:04 
Troschi wrote:
Most of this classes allocate unmanaged resources that are freed by calling their Dispose method, but not when they are collected by the GC.

If they're not freed at all, that's a bug in the class. Classes that allocate unmanaged resources should implement a finalizer (using the 'destructor' syntax in C#, ~ClassName) which frees the resources.

Finalizers have a few problems in the current releases of the Framework. Firstly, the memory is only released on the second collection that hits this object. The first GC detects there are no references to this object and that it has a finalizer, so it puts the object on a finalization queue. A thread that's reserved only for calling finalizers reads this queue and calls the finalizer for each object. Once the finalizer has run, it removes the reference. The next time the GC runs for the appropriate generation (the object is considered to have survived the original collection and is promoted to the older generation) the memory will then be freed.

If you're writing your own classes, you should call GC.SuppressFinalize in your Dispose method to indicate that the object no longer requires finalization. This saves the object surviving unnecessarily.

You should still call Dispose (or use a using block) to avoid the unnecessary memory pressure caused by the implementation of finalization. Consider the finalizer to be a back-stop against failing to call Dispose.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Garbage collector Pin
Stefan Troschuetz27-Apr-04 0:28
Stefan Troschuetz27-Apr-04 0:28 
GeneralDockable main Program Pin
camasmartin26-Apr-04 10:35
camasmartin26-Apr-04 10:35 
GeneralRe: Dockable main Program Pin
surgeproof26-Apr-04 11:18
surgeproof26-Apr-04 11:18 
GeneralSystem.Web.Services.Protocols.SoapException Pin
Code Toad26-Apr-04 9:46
Code Toad26-Apr-04 9:46 
GeneralRe: System.Web.Services.Protocols.SoapException Pin
Heath Stewart26-Apr-04 10:11
protectorHeath Stewart26-Apr-04 10:11 
GeneralRe: System.Web.Services.Protocols.SoapException Pin
Code Toad27-Apr-04 3:58
Code Toad27-Apr-04 3:58 
GeneralCustomizing Controls in c# - Help Pin
stan2826-Apr-04 9:01
stan2826-Apr-04 9:01 
GeneralRe: Customizing Controls in c# - Help Pin
Heath Stewart26-Apr-04 9:28
protectorHeath Stewart26-Apr-04 9:28 
GeneralRe: Customizing Controls in c# - Help Pin
stan2827-Apr-04 3:26
stan2827-Apr-04 3:26 
GeneralRe: Customizing Controls in c# - Help Pin
Heath Stewart27-Apr-04 3:41
protectorHeath Stewart27-Apr-04 3:41 
GeneralSending POST HTTP request truncates the last character Pin
Le centriste26-Apr-04 8:15
Le centriste26-Apr-04 8:15 
GeneralRe: Sending POST HTTP request truncates the last character Pin
Heath Stewart26-Apr-04 8:54
protectorHeath Stewart26-Apr-04 8:54 
GeneralGDI+ OnPaint Pin
mookeroo26-Apr-04 5:54
mookeroo26-Apr-04 5:54 
GeneralRe: GDI+ OnPaint Pin
Heath Stewart26-Apr-04 6:10
protectorHeath Stewart26-Apr-04 6:10 
GeneralRe: GDI+ OnPaint Pin
mookeroo27-Apr-04 0:52
mookeroo27-Apr-04 0:52 
AnswerRe: Splitting a string into a substring and into chars? Pin
Jeff Varszegi26-Apr-04 5:15
professionalJeff Varszegi26-Apr-04 5:15 
AnswerRe: Splitting a string into a substring and into chars? Pin
Jon G26-Apr-04 5:30
Jon G26-Apr-04 5:30 

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.