Click here to Skip to main content
15,897,187 members
Home / Discussions / C#
   

C#

 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 20:31
N a v a n e e t h23-Oct-07 20:31 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 20:45
lmoelleb23-Oct-07 20:45 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 20:59
N a v a n e e t h23-Oct-07 20:59 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 21:17
lmoelleb23-Oct-07 21:17 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 21:21
N a v a n e e t h23-Oct-07 21:21 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 21:27
lmoelleb23-Oct-07 21:27 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 21:32
N a v a n e e t h23-Oct-07 21:32 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 22:45
lmoelleb23-Oct-07 22:45 
1) No, classes do not have a default finalize and if you do not add one nothing will be called.

2) A Finalizer is not needed if you have no unmanaged code to clean up (as you can see in my example, nothing happens in the finalizer if there are no unmanaged references.

3) Yes, a finalizer can impact performance - as I wrote in a comment in my example a finalizer will force the object to be promoted a generation in the garbage collector before it is released (which does not matter if it is a single object you dispose when closing the application, but for something you use a lot it is a problem).

However you will see that the call to Dispose result in a call to GC.SuppressFinalize(this) which basically disable the finalizer for the object once it has been Disposed (as we have cleaned up the references no need to call it again). This elimintes the performance hit when Disposed is used correctly (as you should always be carefull to do with objects implementing IDisposable).
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 23:01
N a v a n e e t h23-Oct-07 23:01 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:18
professionalScott Dorman24-Oct-07 1:18 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:19
professionalScott Dorman24-Oct-07 1:19 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:36
professionalScott Dorman24-Oct-07 1:36 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb24-Oct-07 2:35
lmoelleb24-Oct-07 2:35 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 12:46
professionalScott Dorman24-Oct-07 12:46 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:22
professionalScott Dorman24-Oct-07 1:22 
Questionupdate from combobo to textbox Pin
kabutar23-Oct-07 19:54
kabutar23-Oct-07 19:54 
AnswerRe: update from combobo to textbox Pin
Christian Graus23-Oct-07 20:02
protectorChristian Graus23-Oct-07 20:02 
GeneralRe: update from combobo to textbox Pin
kabutar23-Oct-07 20:07
kabutar23-Oct-07 20:07 
Questioninsertion of nature of comment row. [modified] Pin
alok217123-Oct-07 19:43
alok217123-Oct-07 19:43 
AnswerRe: insertion of nature of comment row. Pin
Christian Graus23-Oct-07 19:51
protectorChristian Graus23-Oct-07 19:51 
AnswerRe: insertion of nature of comment row. Pin
N a v a n e e t h23-Oct-07 19:53
N a v a n e e t h23-Oct-07 19:53 
AnswerRe: insertion of nature of comment row. Pin
Guffa23-Oct-07 20:26
Guffa23-Oct-07 20:26 
QuestionHow to show current progress and progress bar..? Pin
Pankaj - Joshi23-Oct-07 19:36
Pankaj - Joshi23-Oct-07 19:36 
AnswerRe: How to show current progress and progress bar..? Pin
Christian Graus23-Oct-07 19:56
protectorChristian Graus23-Oct-07 19:56 
AnswerRe: How to show current progress and progress bar..? Pin
Abhijit Jana23-Oct-07 21:25
professionalAbhijit Jana23-Oct-07 21:25 

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.