I have a custom patch for Quartz Composer that is a multicast receiver. It fires up a NSThread for the daemon and then restarts it when the user changes the multicast address or port number.
When the patch starts I do the following to launch a new thread.
daemonThread = [NSThread alloc];
Then, every time I start or restart the thread I reinitialize it like:
[daemonThread initWithTarget:multicastDaemon selector:@selector(doWorkWithDelegate:) object:self];
[daemonThread start];
Of course, I terminate the thread each time before I restart it. I’m not using garbage collection, and I do release the daemonThread when the patch exits.
My concern is that I’m not sure what happens when I re-initialize this thread over and over like that. I’ve noticed that Instruments tells me I’m leaking an NSThread and a autoreleasepool, which I suspect may be my pool from the daemon thread. I can see that these numbers increment each time I restart the process, but I’m not familiar enough with Instruments to know what it’s telling me.
Should I be worried?
It is not safe to call any
init...method on any object that has already been initialized. This includes NSThread.