473,804 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A garbage collector for C++

Hello everyone.

I have written a garbage collector for standard C++ application. It has
following main features.

1) Deterministic Finalization
Providing deterministic finalization, the system can manage resources
as well as objects. The programming style is clear and easy, conforming
to RAII (Resource Acquisition Is Initialization) idiom of C++
programmers. The memory usage is very efficient, acyclic garbage is
reclaimed when the last reference to it is removed. A well-designed
application, which eliminates cyclic data structure, does not need
expensive garbage collection and is always running with minimum memory
usage.

2) Accurate GC for C++
It is a fully accurate tracing garbage collector. All garbage objects
are identified by the system, no conservative stack frame guessing.
Fully C++ optimization compiler support.

3) No Pause (less than 1us)
In this system, all application codes automatically become fully
interruptible and GC-Safe. Therefore, scavenge can start at any place
without rendezvous requirement. A special concurrent tracing garbage
collector successfully evades root-set scanning, and does not cause
suspension of any thread at all. In the worst racing case, the latency
is less than one microsecond (not millisecond). It is very satisfied
for real-time systems.

4) Small Overhead
The runtime cost of application threads is far less than a normal
reference counting. If there is no concurrently running scavenging
action, there is no write-barrier overhead, no strong memory ordering
requirement, no synchronization overhead. There is no extra code or
data structure injected for GC safe point. The whole system does not
require strong memory ordering, it is suitable for most modern
processor architecture. Multi-processor concurrency can be further
exploited by the multi-threading property of mutator and collector.

5) Compatible Object Model
As well as conventional C++, the system supports multiple-inheritance,
object as member variables, and object arrays. Support C++ raw pointer,
unions, bit-fields and hidden pointers. Support C++ templates. Support
native object and tracing.

6) Widely Portable
Even conducting an accurate tracing, the system does not require any
special information from compiler. Application can use any standard C++
compiler, such as Visual C++ 8 and GCC. There is no special platform
requirement, such as Win32 system call: SuspendThread, GetWriteWatch,
etc. Even virtual memory support is not necessary. Thus, it can be
ported to a wider area.

Does anyone have any interest in this system? Any comments are welcome!

Mingnan G.

Apr 22 '06
13 3818
Mingnan G. wrote:
I am glad to see your kindly messages and suggestions, thanks very
much.

I am still carefully reading your posts and links. Followings are
questions I know to answer.

What sort of transactions occur between your collector and its mutators during a "scavenge" operation?


During a "scavenge" operation, the system uses multi-threading
synchronization mechanism between collector and mutators. There is some
overhead. However, since most objects are acyclic, scavenge operation
need not run as frequently as prior-art garbage collector. I recommend
tracing garbage collection runs with higher priority than normal
application threads, but lower than real-time threads. So that,
expensive tracing GC can finished sooner, and real-time threads are not
affected.

Do your mutators have any #StoreLoad dependencies during a scavenge operation? I take it that the collector can indeed interrupt mutators during scavenges, correct?


Mutators have #StoreLoad dependencies during a scavenge operation. The
collector can interrupt any application threads at any place, and start
a tracing collection without delay.


Humm... I am curious as to how you are implementing the interrupt logic???
Apr 23 '06 #11
Interrupt logic in this system is quite straight. All application code
is fully interruptible, so the mutator can be interrupted at any place.
If an application thread invoke the garbage collection, the thread
immediately enter the scavenge stage and starts traversals. Other
mutators keep running concurrently with the thread, which become the
collector. During the scavenge stage you can do anything, including
creating new threads, creating new GC objects, etc. Higher priority
threads might preempt the collector at any place, but this will cause
the collector running longer to finish a collection.

Mingnan G.

Apr 24 '06 #12
I do not quite understand your "per-epoch" smart pointers. In this
system, smart pointers physically is just a word of object address. It
traps assignment to pointers. Converting a strong smart pointer to a
raw pointer has no overhead through C++ compiler's optimization, just
like normal C/C++ pointer casting. On the contrary, converting a raw
pointer to strong smart pointer will indead cause a little overhead.
The overhead is very small and in most cases programmers should not
convert a raw pointer to a strong pointer. A strong pointer normally
should derived from another strong pointer. Convertion between strong
pointers is faster than converting from raw pointers.

Mingnan G.

Apr 24 '06 #13
Mingnan G. wrote:
... you could just post links to download and documentation.

Thanks for your kind advice. I am doing that currently. I need a place
to put my documentation and source code, and I need some time.


Why not release it as a sourceforge project? Sourceforge was created for
that exact purpose. It offers web hosting, CVS/subversion, project forums,
bug tracking and some other stuff I don't remember right now.

Here is the URL: http://sourceforge.net/
Hope this helps
Rui maciel
--
Running Kubuntu 5.10 with KDE 3.5.2 and proud of it.
jabber:ru****** **@jabber.org
Apr 24 '06 #14

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

Similar topics

1
2339
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!
10
2056
by: pachanga | last post by:
The Hans-Boehm garbage collector can be successfully used with C and C++, but not yet a standard for C++.. Is there talks about Garbage Collector to become in the C++ standard?
5
5496
by: Ben | last post by:
Could someone please verify if what I am doing as follow is corrected: 1. when dealing with custom class objects: ..... public myObject as myClass myObject as New myClass .......here I am going to fill up myObject with info....tons of them myObject = nothing System.GC.Collect()
2
426
by: lelandguo | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the system can manage resources as well as objects. The programming style is clear and easy, conforming
28
3193
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...
142
6873
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory chunks and recycles them. This memory allocation strategy has been adapted to C (and C++) by the library written by Hans J Boehm and Alan J Demers. Why a Garbage Collector? -----------------------
8
1796
by: Paul.Lee.1971 | last post by:
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...
56
3721
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()
46
2196
by: Carlo Milanesi | last post by:
Hello, traditionally, in C++, dynamically allocated memory has been managed explicitly by calling "delete" in the application code. Now, in addition to the standard library strings, containers, and auto_ptrs, gurus suggest that may be better to use a reference-counted smart pointer, or a garbage-collector. But in which cases it is better to use one technique and in which cases another? IOW, which is the design criterion?
0
9706
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
9582
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
10580
Oralloy
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...
0
10335
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
10082
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...
0
9157
agi2029
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...
0
6854
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();...
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
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.