garbage collector
-
hi all i was asked in interview how often the garbage collector i.e. gc.collect() will get invoked i know why? what? about garbage collectore but interviewer asked me will it be for every 5 minutes the method invokes can anyone help me... bye
-
hi all i was asked in interview how often the garbage collector i.e. gc.collect() will get invoked i know why? what? about garbage collectore but interviewer asked me will it be for every 5 minutes the method invokes can anyone help me... bye
When 1) a memory allocation request exceeds the current generation 0 segment capacity (or because of an exlicit call to GC.Collect) and 2) the object is no longer reachable. If we exclude GC.Collect calls, this means that a GC will only occur on allocation. In other words, objects may well be ready to be released but no allocations are made, meaning no GCs will occur, so memory usage will stay flat.
*jaans
-
hi all i was asked in interview how often the garbage collector i.e. gc.collect() will get invoked i know why? what? about garbage collectore but interviewer asked me will it be for every 5 minutes the method invokes can anyone help me... bye
kalyan_2416 wrote:
how often the garbage collector i.e. gc.collect() will get invoked
Gc.Collect()
will invoke garbage collector immediately. But AFAIK, we can't predict the timings when GC invoked whenCollect()
is not used. I guess it will be invoked when a cleanup is required.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
hi all i was asked in interview how often the garbage collector i.e. gc.collect() will get invoked i know why? what? about garbage collectore but interviewer asked me will it be for every 5 minutes the method invokes can anyone help me... bye
-
When 1) a memory allocation request exceeds the current generation 0 segment capacity (or because of an exlicit call to GC.Collect) and 2) the object is no longer reachable. If we exclude GC.Collect calls, this means that a GC will only occur on allocation. In other words, objects may well be ready to be released but no allocations are made, meaning no GCs will occur, so memory usage will stay flat.
*jaans
k thanx got it
-
kalyan_2416 wrote:
how often the garbage collector i.e. gc.collect() will get invoked
Gc.Collect()
will invoke garbage collector immediately. But AFAIK, we can't predict the timings when GC invoked whenCollect()
is not used. I guess it will be invoked when a cleanup is required.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
nice quote yup the other friend also says what u have guessed thanx bye
-
kalyan_2416 wrote:
how often the garbage collector i.e. gc.collect() will get invoked
Gc.Collect()
will invoke garbage collector immediately. But AFAIK, we can't predict the timings when GC invoked whenCollect()
is not used. I guess it will be invoked when a cleanup is required.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
IIRC explicitly calling GC.Collect() is generally a bad idea. The deal is that it will encourage the garbage collector to promote objects that survive collection to a higher generation. The higher generations are collected less aggressively - which has obvious performance implications.
Mark Churchill Director Dunn & Churchill
-
IIRC explicitly calling GC.Collect() is generally a bad idea. The deal is that it will encourage the garbage collector to promote objects that survive collection to a higher generation. The higher generations are collected less aggressively - which has obvious performance implications.
Mark Churchill Director Dunn & Churchill
You recall correctly. There aren't many occassions, (I can't think or any offhand), where you should call it - let the runtime determine this.
Deja View - the feeling that you've seen this post before.
-
You recall correctly. There aren't many occassions, (I can't think or any offhand), where you should call it - let the runtime determine this.
Deja View - the feeling that you've seen this post before.
You may consider GC.Collect() when you want to get an optimal and/or repeatable starting condition, examples: - application has busy and idle periods, and wants to off-load as much work as possible from the busy to the idle periods - application is going to be observed/measured (as in the Setup method when using NUnit), say for performance measurements. And yes, these are exceptional situations.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google