ObjC Garbage Collector and MIDI Thread
ObjC Garbage Collector and MIDI Thread
- Subject: ObjC Garbage Collector and MIDI Thread
- From: Camille Troillard <email@hidden>
- Date: Thu, 15 Jul 2010 16:10:27 +0200
Hello,
I am working on a Cocoa application that runs on Mac OS X 10.5 and
10.6, and needs to receive MIDI packets. The timing accuracy does not
need to be super precise and no audio is produced, therefore the use
of the garbage collector appears to be a very interesting option.
When the first MIDI packet is received, a GC warning is logged saying
that the current (MIDI) thread has not been registered with the
garbage collector. I have filled a bug report to say that this thread
should be registered automatically with the GC if it is in use. The
answer I got was that neither Objective-C, CoreFoundation, and
obviously garbage collection should be used in the MIDI thread because
of the real time constraints imposed by CoreMIDI.
I first tried to find a workaround by making sure that the code was
making no allocations. Unfortunately, every solutions I tried are
ultimately making a call to the garbage collector.
Luckily, I found a piece of code in the FireWire library
(http://www.opensource.apple.com/source/IOFWDVComponents/IOFWDVComponents-199.4.1/DVLib.c)
that registers the current thread with the garbage collector via a
call to objc_registerThreadWithCollector(), which is a public API on
10.6 and private on 10.5. Everything seems to be working great, and
the warning log is gone as expected.
My question is the following: is there a reason why I wouldn't want
to do that? Am I overlooking something obvious? Using the garbage
collector in this application is a real bonus.
Best Regards,
Camille
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden