Click here to Skip to main content
15,885,856 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can i use GC.Collect() ? Pin
engsrini2-Apr-07 13:16
engsrini2-Apr-07 13:16 
GeneralRe: Can i use GC.Collect() ? Pin
Christian Graus2-Apr-07 13:21
protectorChristian Graus2-Apr-07 13:21 
GeneralRe: Can i use GC.Collect() ? Pin
engsrini2-Apr-07 13:30
engsrini2-Apr-07 13:30 
GeneralRe: Can i use GC.Collect() ? Pin
Christian Graus2-Apr-07 13:40
protectorChristian Graus2-Apr-07 13:40 
QuestionRe: Can i use GC.Collect() ? Pin
JacquesDP2-Apr-07 21:11
JacquesDP2-Apr-07 21:11 
AnswerRe: Can i use GC.Collect() ? Pin
Christian Graus2-Apr-07 21:59
protectorChristian Graus2-Apr-07 21:59 
GeneralRe: Can i use GC.Collect() ? Pin
JacquesDP2-Apr-07 22:03
JacquesDP2-Apr-07 22:03 
GeneralRe: Can i use GC.Collect() ? Pin
Scott Dorman2-Apr-07 14:44
professionalScott Dorman2-Apr-07 14:44 
One of the reasons to not call GC.Collect() that CG hasn't mentioned directly is that when a garbage collection cycle runs, it runs on a different thread than your application. In order for the GC to determine which objects are available for collection, it must freeze your application's main thread. This means that the more time spent in garbage collection, the less time your application has to run.

Eventually, you will start to see performance problems as your application spends more time in a frozen state.

The best option is to ensure that you dispose of objects as early as possible by calling Dispose or by using the using syntax. As you mentioned, setting the object to null is a good way to inform the GC that the object is eligible for collection because it helps ensure that there are no references to that object remaining.

There are a lot of good references on the Dispose pattern and how the garbage collector works. Look at this article, and the references section:

http://www.codeproject.com/useritems/idisposable.asp[^]

-----------------------------
In just two days, tomorrow will be yesterday.

QuestionRe: Can i use GC.Collect() ? Pin
Martin#2-Apr-07 21:24
Martin#2-Apr-07 21:24 
AnswerRe: Can i use GC.Collect() ? Pin
Scott Dorman3-Apr-07 1:05
professionalScott Dorman3-Apr-07 1:05 
GeneralRe: Can i use GC.Collect() ? Pin
Martin#3-Apr-07 4:05
Martin#3-Apr-07 4:05 
GeneralRe: Can i use GC.Collect() ? Pin
Martin#2-Apr-07 20:28
Martin#2-Apr-07 20:28 
QuestionSetting 'OnClick' for dynamic button in Code behind Pin
Chris McGlothen2-Apr-07 11:59
Chris McGlothen2-Apr-07 11:59 
QuestionScheduling (user input time = system time Pin
orly00132-Apr-07 11:37
orly00132-Apr-07 11:37 
AnswerRe: Scheduling (user input time = system time Pin
Judah Gabriel Himango2-Apr-07 13:06
sponsorJudah Gabriel Himango2-Apr-07 13:06 
AnswerRe: Scheduling (user input time = system time Pin
Leslie Sanford2-Apr-07 16:40
Leslie Sanford2-Apr-07 16:40 
QuestionClosing ComboBox DropDownList Programmatically Pin
freshonlineMax2-Apr-07 10:49
freshonlineMax2-Apr-07 10:49 
AnswerRe: Closing ComboBox DropDownList Programmatically Pin
Judah Gabriel Himango2-Apr-07 13:04
sponsorJudah Gabriel Himango2-Apr-07 13:04 
QuestionShowDialogue Pin
AAKAra2-Apr-07 10:32
AAKAra2-Apr-07 10:32 
AnswerRe: ShowDialogue Pin
Christian Graus2-Apr-07 12:26
protectorChristian Graus2-Apr-07 12:26 
GeneralRe: ShowDialogue Pin
AAKAra3-Apr-07 7:05
AAKAra3-Apr-07 7:05 
GeneralRe: ShowDialogue Pin
AAKAra3-Apr-07 7:25
AAKAra3-Apr-07 7:25 
QuestionHow to get to DVD drive without getting access to CD drive? Pin
Khoramdin2-Apr-07 10:16
Khoramdin2-Apr-07 10:16 
Questioncomputer name to IP address Pin
marwan_siala2-Apr-07 9:52
marwan_siala2-Apr-07 9:52 
AnswerRe: computer name to IP address Pin
stancrm2-Apr-07 19:44
stancrm2-Apr-07 19:44 

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.