← Back to team overview

ooc-dev team mailing list archive

Re: About garbage collection

 

Yeah, that comes as a surprise to most people.
There's a dynamic allocation because it could be any size, and you can't
just use a pointer because it has to be by-value semantics.
Although in ArrayListIterator the gc_malloc could definitely be avoided, I
agree.
If you're on IRC these days we could take a look at it together, I just
finished half my exams and have some time now.
Amos---- Original Message ----
From: Damian
To: "Amos Wenger"
Cc: "Ooc dev"
Sent: Fri, Dec 24, 2010, 16:03 PM
Subject: Re: [Ooc-dev] About garbage collection

Well, I'm finally trying to remove the gc and see how the game perfroms.But
I have a problem doing so:This code (taken from ArrayListIterator):
    next: func -> T {         element := list get(index)        index += 1
       return element    }
 compiles to this:
void
structs_ArrayList__ArrayListIterator_next_impl(structs_ArrayList__ArrayListIterator*
this, uint8_t* __genericReturn41) {     uint8_t* element =
lang_Memory__gc_malloc(((lang_Iterators__Iterable*)this)->T->size);
structs_ArrayList__ArrayList_get(this->list, element, this->index);
this->index += 1;    if (__genericReturn41) {
lang_Memory__memcpy(__genericReturn41, element,
((lang_Iterators__Iterable*)this)->T->size);    }     return;}
And I don't get it. I've also seen that a simple declaration like this:
var:Tcompiles to this:uint8_t* var =
lang_Memory__gc_malloc(((lang_Iterators__Iterable*)this)->T->size);
Why is the allocation made?Also, I have no chance to release this memory,
right?
Thanks.Damian
On Mon, Dec 20, 2010 at 10:08 AM, Damian Troncoso  wrote:
 Thanks, I will try the parallel mode on the boehm gc as soon as I have a
little time and tell you about the results.  I've read about the immix
implementation of that guy before. He has not implemented defragmentation.
Maybe that's the reason of the faster collection cycles. I don't think I
want to implement a garbage collector by myself. At least not from scratch.

My game is about using letters to make words. It uses a physics engine and
the letters are into bubbles moving in the screen. That's why the
collection lag is so noticeable.
 About rock, yes I've found some bugs that made me change my code to
something else because rock just don't like some things. The biggest
problem was founding where in my code the problem was. And the error
reports are wrong most of the times.
Are you planning on releasing rock 1.0? I thought it was abandoned or so
and oc would have the attention now.
Well, thanks a lot again!!Damian

El 20/12/2010, a las 06:07, Amos Wenger  escribió:
Hey there - just a quick response, hopefully followe by a more detailed one
later but I'm on the clock here :)

The Boehm GC does have a "parallel collection" mode, I have never tried it
but it's documented here:
(http://www.hpl.hp.com/personal/Hans_Boehm/gc/gcdescr.html)http://www.hpl.hp.com/personal/Hans_Boehm/gc/gcdescr.html
(http://www.hpl.hp.com/personal/Hans_Boehm/gc/gcdescr.html)
 (see "Mostly Parallel Garbage Collection")

Apparently it can be enabled with '--enable-parallel-mark' at ./configure
time, see:
(http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html)http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html
(http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html)
Also, if the Boehm GC appears to be not quite fast enough, you might
consider another approach:
(http://gamehaxe.com/tag/immix/)http://gamehaxe.com/tag/immix/
(http://gamehaxe.com/tag/immix/)
 This guy has implemented the IMMIX algorithm for garbage collection and it
seems fast enough - also, he explains that he's triggering garbage
collection
once per frame - you might want to try that so you get shorter, less
noticeable pauses.
Also, what is your game about? :) Has anything annoyed you in rock lately?
Are you looking forward to oc? Do you think rock should be released in 1.0?

Amos
 ---- Original Message ----
From: Damian
 To: "Ooc dev"
 Sent: Mon, Dec 20, 2010, 3:53 AM
Subject: [Ooc-dev] About garbage collection

Hi,this is not really a question about ooc, but I'm looking for some help,
maybe someone can point me out something. I'm developing an iphone game in
ooc, I'm really happy with what I have now, but I'm having a problem with
garbage collection. I managed to configure and build Boehm GC for the
iphone, and it works well but the collection cycle produces a freeze of
about 120 miliseconds, and it's relly notorious and awful. I tried to
configure it, but all I could achieve is having a collection cycle about
every 10 seconds (instead of the 2 or 3 seconds I was having). I've read in
ooc documentation about writing a custom sdk and do memory management, but
I don't want to let to the garbage collection.Has anyone an idea of what
can I do? Is there another way of garbage collection suitable for a game? I
don't know if there is a garbage collection that does the collection in a
background thread, I think boehm gc does not
Well. Any help will be greatly appreciated.Thanks! Damian.