473,804 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1794
On 5 Mar, 16:44, "Paul.Lee.1 971" <Paul.Lee.1...@ googlemail.comw rote:
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...@operam ail.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.co mwrote:

<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.co m>
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.co mwrote:

<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.co mwrote:
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.co m>
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
810
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
2739
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 this? Is it because C is generally a 'low level' language and they didn't want garbage collection to creep into C++ and ruin everything? Just wondering :)
34
6436
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, probably a few hundred lines of code in Python. There is a need to interact with network using the socket module, and then probably a need to do something hardware- related which will get its own driver written in C.
5
3619
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 measurement exactly 10 ms apart. In the future this may decrease to 5ms ). I am concerned that if garbage collection invokes during this time it may interfere with our measurement results. I have looked over the garbage collection mechanism and see no...
8
3052
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 the mainline. The class that instantiated the object in question is definitely still in existence at the point garbage collection swoops in and yanks it out from under my processing. Is there a way to ensure an instantiated object cannot be freed...
28
3191
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 this work be library based or language based and will it be based on that of managed C++? Then of course there are the finer technical questions raised (especially due to pointer abuse). Is a GC for C++ just a pipe dream or is there a lot of work...
56
3720
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 = null; Private Microsoft.Office.Interop.Outlook.NameSpace _Namespace = null; The Constructor: public OutlookObject()
350
11924
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 one, and in what percentage of your projects is one used? I have never used one in personal or professional C++ programming. Am I a holdover to days gone by?
158
7914
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 discouraged due to some specific reason. If someone can give inputs on the same, it will be of great help. Regards, Pushpa
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.