Greetings.
I'm creating a project that as a intricate relation between object kind of
like a set where each object in the set can be connect to a subset of object
of the set and objects not in the set can connect to objects in the set.
Every object inherits a interface to allow for a mark and sweep garbage
collector (GC) and my implementation works correctly and efficiently but
only in a single thread.
How can I garbage collect in a multi-thread program?
With my garbage collector all threads have to stop what they are doing but
in a coherent state before the garbage collector can do it's job. I could
signal all thread that a garbage collection is needed and wait for all the
treads to be ready then execute the garbage collection but it would mean
that some thread would have to wait (possibly a long time) before all thread
are ready and the garbage collector can start.
I have also tried the Hans-Boehm conservative GC (HBGC) in single-thread
(both the interface for my GC and my GC are off) and it worked correctly. It
takes 5-8% more CPU time, very acceptable, but it uses 79-96% more memory
and that is not acceptable (measured max and mix CPU and memory used in 100
test runs). The test runs uses less CPU time and memory than a full run. In
fact in a full run the HBGC would use virtual memory in my 512 MB
development system and that as you can imagine is a big no-no.
Is this excess memory use normal or am I doing something wrong?
Comments are very much appreciated.
Thanks,
Pedro Carvalho 4 2043
Pedro Miguel Carvalho wrote: How can I garbage collect in a multi-thread program?
This is off-topic for C++. Try looking for help in an algorithms
newsgroup, or do a search on the subject of thread synchronization .
Hint: interlock the access to your "ready to garbage collect" member
variable. There's no reason why all threads have to stop when you
garbage collect.
Pedro Miguel Carvalho wrote: I have also tried the Hans-Boehm conservative GC (HBGC) in single-thread (both the interface for my GC and my GC are off) and it worked correctly. It takes 5-8% more CPU time, very acceptable, but it uses 79-96% more memory and that is not acceptable (measured max and mix CPU and memory used in 100 test runs). The test runs uses less CPU time and memory than a full run. In fact in a full run the HBGC would use virtual memory in my 512 MB development system and that as you can imagine is a big no-no.
Hans-Boehm should work fine. If you want to avoid the extra storage it
requires between collection cycles, try adding a reference-counting
mechanism to some of your acyclic structures (for example, by using
smart pointers to refer to them). Then there will be less garbage
building up between cycles. You may also be able to make it collect more
often, or when usage reaches a certain level.
--
Derrick Coetzee
I grant this newsgroup posting into the public domain. I disclaim all
express or implied warranty and all liability. I am not a professional.
"Derrick Coetzee" <dc****@moonfla re.com> wrote in message
news:cj******** **@news-int.gatech.edu. ..
| Pedro Miguel Carvalho wrote:
| > I have also tried the Hans-Boehm conservative GC (HBGC) in single-thread
| > (both the interface for my GC and my GC are off) and it worked
correctly. It
| > takes 5-8% more CPU time, very acceptable, but it uses 79-96% more
memory
| > and that is not acceptable (measured max and mix CPU and memory used in
100
| > test runs). The test runs uses less CPU time and memory than a full run.
In
| > fact in a full run the HBGC would use virtual memory in my 512 MB
| > development system and that as you can imagine is a big no-no.
|
| Hans-Boehm should work fine. If you want to avoid the extra storage it
| requires between collection cycles, try adding a reference-counting
| mechanism to some of your acyclic structures (for example, by using
| smart pointers to refer to them). Then there will be less garbage
| building up between cycles. You may also be able to make it collect more
| often, or when usage reaches a certain level.
| --
| Derrick Coetzee
One of my implementations uses reference-counting smart-pointers for some
objects but for the data set I use a mark-sweep GC. I'm trying to use a GC
because of the extensive cycles that form on my data set so basic
reference-counting will not be a solution. If I make the Hans-Boehm
collector work more then it's use of the CPU also increases.
Thanks,
Pedro Carvalho
"Dave Rahardja" <as*@me.com> wrote in message
news:pX******** ***********@twi ster.rdc-kc.rr.com...
| Pedro Miguel Carvalho wrote:
| > How can I garbage collect in a multi-thread program?
|
| This is off-topic for C++. Try looking for help in an algorithms
| newsgroup, or do a search on the subject of thread synchronization .
Sorry about that. I looked for an appropriate newsgroup. I found various
*.graphics.algo rithms, not appropriate, and various *.comp.algorith ms, none
in english. I will try in comp.programmin g.threads, not exactly what I need,
another off-topic :-).
| Hint: interlock the access to your "ready to garbage collect" member
| variable. There's no reason why all threads have to stop when you
| garbage collect.
To garbage collect the data set I have to be certain that I see a consistent
state, other GC use write/read barriers for this.
Thanks,
Pedro Carvalho This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob |
last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and then throws them away and then monitors the garbage collection and store statistics on it, preferably in C#. I want to know what is the longest period of time that an application may lock up while garbage collection is processing. Thanks!
|
by: Andrew |
last post by:
When will .NET have a low-pause-time garbage collector
A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have to be perfect. For example, I'd be happy with something where there was at most one pause per second, each pause was less than .2 seconds, and half the process's memory was inaccessible to the application due to garbage collection management
It...
|
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
|
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 :)
|
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...
| |
by: Andy |
last post by:
Along with many others I've noticed the large amount of memory that
can be taken up by the aspnet_wp.exe. I've found that I can better
control and limit this memory consumption by including a GC.Collect()
in the Application_EndRequest() event handler in the Global.asax file.
Whilst this appears to help my memory consumption issues I've also
read that forced GC.Collect() can be inefficient.
Assuming that I don't see any adverse effects...
|
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?
|
by: None |
last post by:
Hi,
I am a game developer, sometimes "indy" and sometimes for a small-sized
company. I can't speak for all game developers, but everywhere I've ever
seen people working on games, execution speed has always been the most
important constraint in writing code. Writing readable and maintainable
code is important, but takes a back seat to execution speed.
I work with DirectX and/or OpenGL, always in C++. There are plenty of
things that...
|
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
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |