473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Garbage collection supression

Hi everyone,
A program that I'm helping to code seems to slow down drastically
during initialisation, and looking at the profiling graph, it seems to
be the garbage collector thats slowing things down. I must point out
that a heck of a lot of data are being read in and manipulated, and I
was wondering if there were any metrics to show much of a performance
hit is occurring during the initialisation? If it turns out that the
GC is having a bad effect on the program, is there a way to suppress
the operation of the GC (although this does sound like a very bad idea
IMHO)

TIA

Paul
--
http://www.paullee.com

Mar 5 '07 #1
8 1760
On 5 Mar, 16:44, "Paul.Lee.1971" <Paul.Lee.1...@googlemail.comwrote:
Hi everyone,
A program that I'm helping to code seems to slow down drastically
during initialisation, and looking at the profiling graph, it seems to
be the garbage collector thats slowing things down. I must point out
that a heck of a lot of data are being read in and manipulated, and I
was wondering if there were any metrics to show much of a performance
hit is occurring during the initialisation? If it turns out that the
GC is having a bad effect on the program, is there a way to suppress
the operation of the GC (although this does sound like a very bad idea
IMHO)

TIA

Paul
--http://www.paullee.com
Afraid not. Are you creating and dumping large numbers of objects? If
so, could you create a pool of objects and reuse them for example?

Mar 5 '07 #2
On 5 Mar, 17:13, "DeveloperX" <nntp...@operamail.comwrote:

<snip>
>
Afraid not. Are you creating and dumping large numbers of objects? If
so, could you create a pool of objects and reuse them for example?
Hi,
Yes that is one option we could look at. I'm just thinking about the
hit on program speed due to the GC running.
We have about 0.6MB reclaimed in a second at one point, and then, 3 MB
in a second a little later on. This must impact
the running speed?

Paul
--
http://www.paullee.com
Mar 5 '07 #3
Paul.Lee.1971 wrote:
Hi everyone,
A program that I'm helping to code seems to slow down drastically
during initialisation, and looking at the profiling graph, it seems to
be the garbage collector thats slowing things down. I must point out
that a heck of a lot of data are being read in and manipulated, and I
was wondering if there were any metrics to show much of a performance
hit is occurring during the initialisation? If it turns out that the
GC is having a bad effect on the program, is there a way to suppress
the operation of the GC (although this does sound like a very bad idea
IMHO)

TIA

Paul
--
http://www.paullee.com
Going through a lot of object doesn't autoamtically mean that the
garbage collector has to do a lot of work. What matters is the life span
of the objects.

The garbage collector works by the theory that most objects are very
short lived. All new objects (smaller than 85 kB) are allocated in heap
generation 0, and this is the heap generation that is most often
collected. Collecting a heap genretation is done by moving all used
objects to the next generation and clear out the entire generation.

This means that if you create a lot of object but release them before
the next garbage collection, reclaiming the memory is very cheap. The
garbage collector actually has to do absolute nothing to the objects to
reclaim the memory. When the used objects are removed from the heap
generation, the allocation pointer is reset to the start of the heap
generation, and all the unused objects in it are gone with one single
operaton. Poof.

If you use objects that implement the IDisposable interface, you should
be careful to always call the Dispose method when you are done with
them. Objects that implement IDisposable has a finalizer as backup for
the Dispose method, which means that they are references from the
finalizer queue.

If you call Dispose, the object is removed from the finalizer queue, and
can easily be collected just like any other object. If you don't call
Dispose, the garbage collector has to call the finalizer before the
object can be collected, but calling the finalizer of a lot of objects
takes far too long to do in a garbage collection, so the objects has to
be moved to the next heap generation and wait there for a background
thread to call the finalizer. That means that any disposable object that
is not disposed properly will need at least two garbage collections to
go away.

So, have a look at the life span of the objects you use, and make sure
to dispose disposable objects.

--
Göran Andersson
_____
http://www.guffa.com
Mar 5 '07 #4
Göran Andersson <gu***@guffa.comwrote:

<snip>
If you use objects that implement the IDisposable interface, you should
be careful to always call the Dispose method when you are done with
them. Objects that implement IDisposable has a finalizer as backup for
the Dispose method, which means that they are references from the
finalizer queue.
Just to be clear - *some* types which implement IDisposable also have a
finalizer. It's by no means a requirement, and many types which
implement IDisposable neither have nor need a finalizer. You should
still call Dispose on them though :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 5 '07 #5
Jon Skeet [C# MVP] wrote:
Göran Andersson <gu***@guffa.comwrote:

<snip>
>If you use objects that implement the IDisposable interface, you should
be careful to always call the Dispose method when you are done with
them. Objects that implement IDisposable has a finalizer as backup for
the Dispose method, which means that they are references from the
finalizer queue.

Just to be clear - *some* types which implement IDisposable also have a
finalizer. It's by no means a requirement, and many types which
implement IDisposable neither have nor need a finalizer. You should
still call Dispose on them though :)
Thanks for the correction. :) The recommended implementation of
IDisposable includes using a finalizer, so I thought that most classed
would follow that.

--
Göran Andersson
_____
http://www.guffa.com
Mar 6 '07 #6
Göran Andersson <gu***@guffa.comwrote:
Just to be clear - *some* types which implement IDisposable also have a
finalizer. It's by no means a requirement, and many types which
implement IDisposable neither have nor need a finalizer. You should
still call Dispose on them though :)
Thanks for the correction. :) The recommended implementation of
IDisposable includes using a finalizer, so I thought that most classed
would follow that.
That should only be the recommendation *if* the type directly contains
unmanaged resources. If it only contains references to other types
which contain unmanaged resource (e.g. it has a reference to a stream)
then you shouldn't have a finalizer.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 6 '07 #7
Göran Andersson wrote:
Thanks for the correction. :) The recommended implementation of
IDisposable includes using a finalizer,
You may have been looking at the recommended implementation of a
*finalizable object&, which should include an IDisposable
implementation.

The converse is not necessarily true.

-- Barry

--
http://barrkel.blogspot.com/
Mar 6 '07 #8
Barry Kelly wrote:
Göran Andersson wrote:
>Thanks for the correction. :) The recommended implementation of
IDisposable includes using a finalizer,

You may have been looking at the recommended implementation of a
*finalizable object&, which should include an IDisposable
implementation.

The converse is not necessarily true.

-- Barry
No, I have been looking at the recommended implementation of the
IDisposable interface:

http://msdn2.microsoft.com/en-us/lib...isposable.aspx

--
Göran Andersson
_____
http://www.guffa.com
Mar 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
11
by: Rick | last post by:
Hi, My question is.. if Lisp, a 40 year old language supports garbage collection, why didn't the authors of C++ choose garbage collection for this language? Are there fundamental reasons behind...
34
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
5
by: Bob lazarchik | last post by:
Hello: We are considering developing a time critical system in C#. Our tool used in Semiconductor production and we need to be able to take meaurements at precise 10.0 ms intervals( 1000...
8
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by...
28
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will...
56
by: Johnny E. Jensen | last post by:
Hellow I'am not sure what to think about the Garbage Collector. I have a Class OutlookObject, It have two private variables. Private Microsoft.Office.Interop.Outlook.Application _Application =...
350
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.