The Hans-Boehm gc is open source:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/Now, GC_init() is required on the mac in order to load the dynamic libraries. It can be called more than once. But it says here in the documentation:
"Thread-local GC allocation will not work with threads that are not
created using the GC-provided override of pthread_create(). Threads
created without the GC-provided pthread_create() do not have the
necessary data structures in the GC to store this data."
So if the audio unit is created on another thread, I assume from the above that the state of the heap needs to be set for that
thread. Since the thread is created by the host, Hans-boehm GC may not work at all, or perhaps all allocations to the heap are not Thread-local. I still need to test this.
I think its ridiculous that the operating system provides a garbage collector, but only restricts it to Obj-C pointers.
From: Paul Davis <email@hidden>
To: Brian Willoughby <email@hidden>
Cc: paul Fultz <email@hidden>; Core Audio List <email@hidden>
Sent: Sun, May 23, 2010 8:27:35 PM
Subject: Re: Garbage collector in an audio
unit
On Sun, May 23, 2010 at 7:44 PM, Brian Willoughby
<email@hidden> wrote:
AUBase::Initialize() must be called before any other code in the AU, so you could set a global flag and call the H-b initialize exactly once. However, I don't know what would happen if you have multiple AudioUnits using the same gc or if the host is using the same gc. Does Hans-boehm have any sort of protection against multiple initialize calls? Is it open source?
my recollection is that H-B GC needs to see the state of the heap before most of the program has gotten started. clearly, there must be some fuzziness because you don't know what has happened before you get into main(), but i seem to recall that things can go awry if you initialize it "late" in the process lifecycle.