[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
-[NSThread detachNewThread...] memory management question
From: |
Wim Oudshoorn |
Subject: |
-[NSThread detachNewThread...] memory management question |
Date: |
Wed, 18 Jan 2006 16:51:27 +0100 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/22.0.50 (darwin) |
Hm it looks like I have found a very pitfall to leak memory
when using -[NSThread detachNewThreadSelector:toTarget:withObject:]
Suppose you have somewhere
[NSThread detachNewTheadSelector....
...
withObject: myInterestingObject];
Now when the thread finished, myInterestingObject
is send a release message.
This release message is send WITHOUT having an autoreleasepool in place.
So if the dealloc method of myInterestingObject, triggers
an autorelease on another object this other object will leak.
Is this expected behaviour? Because if it is you have
to ensure in all your code that no dealloc triggers indirectly an autorelease.
This is a big task, because just about any string manipulation creates
autoreleased objects.
Wim Oudshoorn.
- -[NSThread detachNewThread...] memory management question,
Wim Oudshoorn <=