[問題] leak of NSThread
在Stanford教學中
http://www.stanford.edu/class/cs193p/cgi-bin/index.php
有篇NSThrad的Sample : Lecture 10 - LetsMakeAThread
Sample Code連結 :
http://www.stanford.edu/class/cs193p/downloads/10-LetsMakeAThread.zip
他的架構大致如下 :
1. Thread進入點:
[NSThread detachNewThreadSelector:@selector(someFunction)
toTarget:self withObject:nil];
(說明文件有提到,"detachNewThreadSelector:.." method中,
selector function 必須自訂一個autoreleasepool )
2.someFunction 內容: (沒忘了加autoreleasepool)
-(void)someFunction{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSThread sleepforTimeInterval:3];
[self performSelectorOnMainThread:@selector(finishFunction) withObject:nil
waitUntilDown:NO];
[pool release];
}
3.end:
-(void)finishFunction{
...................
}
問題來了,當我把它放上實機跑Insttrument,就出現一根memory leaks
(General Block - 3584)
情形大致就與這篇論壇的情形一樣(有畫面)
http://0rz.tw/4SViG
用這個method去啟動新的NSThread,每啟動一個都會出現memory leak...
不知有無解決之道 :(
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.128.227.51
※ 編輯: lemonstar 來自: 220.128.227.51 (06/08 12:26)
→
06/08 12:26, , 1F
06/08 12:26, 1F
→
06/08 12:28, , 2F
06/08 12:28, 2F
→
06/08 12:34, , 3F
06/08 12:34, 3F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章