473,513 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generational garbage collection

hello ppl,
i am trying to implement a garbage collector for c++ using the
generational algorithm applying mark-sweep to each generation.
i am unable to get any details about the algorithm. is it
necessary that the object allocated in each generation and the
generations themselves be in the form of contigious memory locations.

Aug 25 '05 #1
14 2130
Could you please tell us whether you are referring to managed C++(.NET)
or unmanaged C++? Thank you.

Aug 25 '05 #2

"Arvind" <ar****@yahoo.co.in> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
hello ppl,
i am trying to implement a garbage collector for c++ using the
generational algorithm applying mark-sweep to each generation.
i am unable to get any details about the algorithm. is it
necessary that the object allocated in each generation and the
generations themselves be in the form of contigious memory locations.


Looking into my crystal ball (www.google.com) immediately gives me the
following things you might consider interesting:

http://www.hpl.hp.com/personal/Hans_Boehm/gc/
http://en.wikipedia.org/wiki/Automat...age_collection

HTH
chris
Aug 25 '05 #3
Chris, Arvind is a renowed a computer science processor. He may already
know about the links you found, I think Arvind is looking for people
who have actually worked on C++ garbage collection in academia or
industry(i.e. MSFT). Thank you.

Aug 25 '05 #4

"Frank Chang" <Fr**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Chris, Arvind is a renowed a computer science processor. He may already
know about the links you found, I think Arvind is looking for people
who have actually worked on C++ garbage collection in academia or
industry(i.e. MSFT). Thank you.


Frank,

I acknowledge that Arvind is a renowned computer science expert in the field
of graph theory, quantum computing etc. However, he stated " i am unable to
get any details about the algorithm" which indicates that he has not found
the links. IMHO the forum might not be the best place to discuss a rather
intricate topic like garbage collection to the required detail. Therefore I
posted the links, which describe algorithms in detail to help him getting
started.

Cheers
Chris
Aug 25 '05 #5

Arvind schreef:
hello ppl,
i am trying to implement a garbage collector for c++ using the
generational algorithm applying mark-sweep to each generation.
i am unable to get any details about the algorithm. is it
necessary that the object allocated in each generation and the
generations themselves be in the form of contigious memory locations.


It seems to me the answer is obviously no. Why should it be? The usual
reason for a set of items to be contiguous is so one can easily find
a next item. Exactly how you define 'next' also defines 'contiguous'.
If you don't qualify it, you usually refer to the "natural" order, i.e.
increasing addresses.

So, in this context I assume you'd want to have a contiguous memory
block so you can find the next allocation. However, if the memory
allocator used a linked list, the physical representation would
probably be non-contiguous, but one could still find the next
allocation in the generation.

HTH,
Michiel Salters

Aug 25 '05 #6

"Arvind" <ar****@yahoo.co.in> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
hello ppl,
i am trying to implement a garbage collector for c++ using the
generational algorithm applying mark-sweep to each generation.
i am unable to get any details about the algorithm. is it
necessary that the object allocated in each generation and the
generations themselves be in the form of contigious memory locations.


For mark-sweep GC contiguous memory is not required. However, you might end
up with heavily fragmented memory (depending on your application) and this
could lead to slower reallocation. There are other approaches that
inherently move allocated objects and therefore will automatically result in
contiguous memory. I'd recommend to take a look at
http://www.iecc.com/gclist/GC-faq.html

HTH
Chris
Aug 25 '05 #7
Chris, I apologize. You are right. It seems you know a lot about
garbage collection. Was this experience gained through industry or
school? Thank you.

Aug 25 '05 #8
Chris Theis, I have two reservations about garbage collection in C++ .
The first set of reservations can be found in the link ,
http://www.cs.tut.fi/~warp/MicrosoftComparingLanguages.
The second reservation that the GC-LIST link does not address is the
issue of multiple threads running in a C++ program. How will GC-LIST
handle the memory allocated to each worker thread that is instantianted
when the worker threads finish their tasks? Thank you.

Aug 25 '05 #9

"Frank Chang" <Fr**********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Chris Theis, I have two reservations about garbage collection in C++ .
The first set of reservations can be found in the link ,
http://www.cs.tut.fi/~warp/MicrosoftComparingLanguages.
The second reservation that the GC-LIST link does not address is the
issue of multiple threads running in a C++ program. How will GC-LIST
handle the memory allocated to each worker thread that is instantianted
when the worker threads finish their tasks? Thank you.


Dear Frank,

frankly I share your reservations about GC starting already at the
philosophical design point of view, which is followed by the technical
requirements and overhead that can become very tricky. This is especially
true for multi threading environments. There are different approaches for
this problem like for example safe-points. This means that all threads must
have reached a safe-point before the GC can start its work. However, this
might become a bottleneck as soon as threads with very different priority
levels are involved as it could cause serious delays. Other approaches
include breaking the problem down into single-thread contexts, etc.

You might probably take a look at the following page which hosts a fairly
large collection of papers covering GC thread problems etc.

http://research.sun.com/jtech/pubs/
http://www-128.ibm.com/developerwork...ry/i-garbage2/

HTH
Chris
Aug 26 '05 #10
Chris, let me try again. The last post didn't make it through. Thank
you for explaining safe-points, There is also a good discussion about
safe-points in the link http:/www/ieec.com/gclist/GC-faq.html , Thread
Safety, you provided yesterday. However, the FAQ does not discuss how
the GC-LIst project releases the memory allocated by threads back to
the operating system. Even in managed C++(.NET) , John Skeets writes:
"It's normal for memory not to be released to the OS for potentially a
very long time, and sometimes never. The important thing is that the
memory becomes available as far as .NET is concerned."
I read your links about how IBM resolved GC thread problems in
Java . Given the differences between Java and unmanaged C++, do you
think the Java GC thread solutions can be applied to unmanaged C++?

Aug 26 '05 #11
Chris, If this post appears twice it is because my browser crashed. I
read your link http://www.ieec.com.gclist/GC-faq.html . This article
contains a section, Thread Support, which discusees safe-points.
However, the thread support section does not contain a discussion about
how the GC-List unmanaged C++ garbage collection policy handles
releasing the memory allocated by multiple threads back to the
operating system after the threads have finished their tasks. Even in
managed C++(.NET), I believe it may be true that the memory released by
threads is released to the .NET "VM" rather than the operating system.
I scanned the link concerning Java garbage collection which you
provided but I am not sure if Arvind can apply those same solutions to
unmanaged C++ garbage collection.
I read Arvind's web page about his current research interests. It
is interesting to read. Evidently, Arvind has started two companies
since 2000. I just don't think it would be a good idea to start a
company built around an unmanaged C++ garbage collection framework.
The total revenues of this hypothetical company would be a lot less
than the cost of R&D required to build such a product. Also, it is
uncertain how the unmanaged C++ community react to such a product once
it were introduced. Thank you.

Aug 26 '05 #12

"Frank Chang" <Fr**********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Chris, If this post appears twice it is because my browser crashed. I
read your link http://www.ieec.com.gclist/GC-faq.html . This article
contains a section, Thread Support, which discusees safe-points.
However, the thread support section does not contain a discussion about
how the GC-List unmanaged C++ garbage collection policy handles
releasing the memory allocated by multiple threads back to the
operating system after the threads have finished their tasks. Even in
managed C++(.NET), I believe it may be true that the memory released by
threads is released to the .NET "VM" rather than the operating system.
I scanned the link concerning Java garbage collection which you
provided but I am not sure if Arvind can apply those same solutions to
unmanaged C++ garbage collection.
I read Arvind's web page about his current research interests. It
is interesting to read. Evidently, Arvind has started two companies
since 2000. I just don't think it would be a good idea to start a
company built around an unmanaged C++ garbage collection framework.
The total revenues of this hypothetical company would be a lot less
than the cost of R&D required to build such a product. Also, it is
uncertain how the unmanaged C++ community react to such a product once
it were introduced. Thank you.


Hi Frank,

GC-list is rather a discussion/knowledge base than an actual implementation.
Releasing memory from the GC to the OS is implementation dependent and also
a philosophical question. It can be argued whether it is a good idea to
immediately return memory to the OS pool, but in IMHO for most applications
it is not such a hot idea. If you have a lot of short-lived threads it will
pay off to keep control over the memory, however for long lived threads the
situation can be different. AFAIK many GC implementations delay the release
to the OS as long as possible.

I also think the .NET handles it that way but you might check Mike Zintels
blog for this (http://blogs.msdn.com/mikezintel/default.aspx).
It actually makes sens that the .NET VM is the instance taking care of the
memory for the whole .NET framework as it allows for better control. I
actually would be very cautious investing my money in the R&D for a new
unmanaged C++ GC as there are quite sophisticated open source
implementations already available, but this is a rather personal opinion and
I certainly do not want to discourage anybody from doing this. There is
certainly large room for improvement on the technical side, but I have my
reservations regarding the economical aspects of such an undertaking.

Anyway, you normally can apply the basic ideas of the Java GC also to an
unmanaged C++ GC, but naturally you'll run into big difference regarding the
interfacing. In Java (and C#) the memory management is done mostly under the
hood, whereas in unmanaged C++ it will be the developer who will have to
interface with the GC at some point or the other.

HTH
Chris
Aug 26 '05 #13
Chris: I never meant to infer that GC-LIST was an implementation . I
referred to it as a policy. I apologize for the confusion. The biggest
difference between Java, C# and managed C++(.NET) is that they have an
virtual machine layered on top of the operating system. From all your
links including
http://www.hpl.hp.com/personal/Hans_...c/gcdescr.html, I see no
mention of the fact that garbage collection in unmanaged C++ would use
a virtual machine. For example, gnu has a garbage collection option but
I don't believe they have also built a virtual machine. Therefore, in
unmanaged C++ GC , the memory allocated by threads should be released
to the operating system. Also , could you please tell me why there is a
difference between short-lived threads and long-lived threads?

Aug 26 '05 #14
Chris, Sorry for the typo : It should read:

The biggest difference between Java, C# and managed C++(.NET)
versus unmanaged C++ is that Java, C#, managed C++ all have an virtual
machine layered on top of the operating system.

I think you alluded to this in your last post,
"In Java (and C#) the memory management is done mostly under the
hood, whereas in unmanaged C++ it will be the developer who will have
to interface with the GC at some point or the other"

Aug 26 '05 #15

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

Similar topics

0
1480
by: Marc Lehmann | last post by:
Hello Group, I'm working on a seminar talk about generational garbage collection in the Java HotSpot enginge. Now most things are quite clear to me, but there's a question I didn't find an...
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
2713
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...
5
3561
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
3013
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
3133
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
3620
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
11459
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
7692
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
7260
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,...
0
7384
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,...
0
7539
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...
0
7525
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...
0
5686
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,...
1
5089
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...
0
1596
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 ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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...

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.