I'm sure this has probably been vigorously debated already but has any thought been given to using reference counting instead of the garbage collection in shedskin? If so, what was the rational? Thanks.
> I'm sure this has probably been vigorously debated already but has any
> thought been given to using reference counting instead of the garbage
> collection in shedskin?
> If so, what was the rational?
Issues with garbage collection have been raised several times indeed,
and more or less addressed, but I don't remember reference counting
having been considered as a serious alternative to it.
Implementing an efficient memory management system based on reference
counting like in CPython¹ is not a trivial task, as you have to handle
corner cases such as cyclic references for example. Mark and Sweep
does not have such issue.
But I guess the main reason for using BoehmGC is that it's ready to work :-)
It's not perfect, in that reference loops are still possible if the user does not take care but it bypasses the terrible performance of GC when using lots of objects.
On Friday, 24 August 2012 10:31:13 UTC+1, Roquet wrote:
> Hi Gearoid,
> 2012/8/24 Gearoid Murphy <gearoid....@gmail.com <javascript:>>: > > I'm sure this has probably been vigorously debated already but has any > > thought been given to using reference counting instead of the garbage > > collection in shedskin? > > If so, what was the rational?
> Issues with garbage collection have been raised several times indeed, > and more or less addressed, but I don't remember reference counting > having been considered as a serious alternative to it. > Implementing an efficient memory management system based on reference > counting like in CPython¹ is not a trivial task, as you have to handle > corner cases such as cyclic references for example. Mark and Sweep > does not have such issue.
> But I guess the main reason for using BoehmGC is that it's ready to work > :-)
> It's not perfect, in that reference loops are still possible if the user
> does not take care but it bypasses the terrible performance of GC when using
> lots of objects.
No, I'm not familiar with it (I don't own any Apple device, actually).
This may be worth a look. In particular, it would be interesting to
know if this has been chosen for global performance reasons, or maybe
because working on mobile devices matters.
> But I guess the main reason for using BoehmGC is that it's ready to work
> :-)
yeah, iirc, it took about an hour to get the boehm gc to "work". I've never
really thought about refcounting after that, other than to note that it
seems messy business.
I quote "work" above because I've encountered/received several python
programs by now that trip up the GC after compilation (memory allocation
goes through the roof because it is unable to deallocate anything). it
would be great if anyone could look into this problem with some depth.. see
for example one of the currently open issues.
> It's not perfect, in that reference loops are still possible if the user
> does not take care but it bypasses the terrible performance of GC when
> using lots of objects.
not sure but I seem to remember C++ also has this capability (read: can be
extended to have it), in the form of "smart" or "shared pointers". but
again I've never really looked into this stuff . (note these may not be
compatible with the boehm gc.. :S)
Yes, there are scoped pointers, shared pointers, reference-counting
pointers, etc. Currently, all allocators are from the boehm gc, but if
shedskin allowed different allocators or at least allocation syntax, then
you could swap in reference-counting pointers that take care of the
reference counting internally to the pointer object (each
construction/destruction for the same pointer value is a
reference/dereference). With some more work, and likely escape-analysis,
scoped pointers/stack allocation could be used (scoped pointers are usually
used when creation of an object is conditional and there are multiple
return points from the function, or as a instance variable that may come in
as NULL but ownership is taken).
>> It's not perfect, in that reference loops are still possible if the user
>> does not take care but it bypasses the terrible performance of GC when
>> using lots of objects.
> not sure but I seem to remember C++ also has this capability (read: can be
> extended to have it), in the form of "smart" or "shared pointers". but
> again I've never really looked into this stuff . (note these may not be
> compatible with the boehm gc.. :S)
> --
> You received this message because you are subscribed to the Google Groups
> "shedskin-discuss" group.
> To post to this group, send email to shedskin-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> shedskin-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/shedskin-discuss?hl=en.