PDFファイルでこの簡単なコードを実行する
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSURL *url = [NSURL fileURLWithPath: @"/Users/pc/Desktop/C# 4.0 in a Nutshell The Definitive Reference.pdf"];
PDFDocument *document = [[PDFDocument alloc] initWithURL:url];
[document release];
}
そしてそれをインストゥルメントで実行すると、次のようにメモリリークが発生します
少し調査したところ、一部の PDF ファイルでのみ発生することがわかりました。その他のファイルは、Instrument でリーク警告なしで実行されます。
これは PDFKit のバグですか?
アップデート
このコードを数回実行すると、メモリが真剣に上がります
-(IBAction) test: (id) sender
{
NSLog(@"Starting");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *url = [NSURL fileURLWithPath: @"/Users/pc/Desktop/C# 4.0 in a Nutshell The Definitive Reference.pdf"];
for (int i=0; i<100; i++)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
PDFDocument *document = [[PDFDocument alloc] initWithURL:url];
[document release];
[pool release];
}
[pool release];
}