Re: -[NSView dataWithPDFInsideRect:] leaks
Re: -[NSView dataWithPDFInsideRect:] leaks
- Subject: Re: -[NSView dataWithPDFInsideRect:] leaks
- From: Matt Neuburg <email@hidden>
- Date: Sat, 8 Jun 2002 07:31:06 -0700
Returning to this thread - I just encountered this problem independently.
Every ten seconds or so I was using dataWithPDFInsideRect to capture a
view's contents and use them as my app's dock icon; my app eventually ate
all the computer's memory.
Ondra's hint is a good one, though. You can get rid of most of the leak by
adding [anImage recache] just before releasing it. But I was never quite
able to get rid of all of it, and in the end I had to abandon use of
dataWithPDFInsideRect altogether. A pity, since it's a very cool method. m.
On Thursday, April 18, 2002, at 08:11 , Peter Sichel wrote:
>
>
>
>>The code below works, but leaks from -dataWithPDFInsideRect
>
>
>
>You sure it's a leak (and not just a cache)?
>
>---
>
>Ondra Cada
>
>
Yes, the leaks are clearly visible in MallocDebug.
>
Changing the code to this made no difference:
>
>
if ([[self window] isMiniaturized]) {
>
NSImage* anImage;
>
NSData* pdfData;
>
NSAutoreleasePool *pool;
>
pool = [[NSAutoreleasePool alloc] init];
>
// get the desired image
>
pdfData = [plotView dataWithPDFInsideRect:[plotView bounds]];
>
[pdfData retain];
>
anImage = [[NSImage alloc] initWithData:pdfData];
>
[[self window] setMiniwindowImage:anImage];
>
[anImage release];
>
[pdfData release];
>
[pool release]; // releases all autoreleased
>
objects including pdfData
>
}
>
>
In MallocDebug "Definite Leaks" shows a number of 40 byte
>
blocks while getting and parsing the device plist as follows:
>
>
320 bytes in 8 nodes:
>
malloc
>
CFAllocatorAllocate
>
_CFRuntimeCreateInstance
>
__CFDictionaryInit
>
CFDictionaryCreateMutable
>
parseDictTag
>
parseXMLElement
>
getContentObject
>
parseDictTag
>
parseXMLElement
>
getContentObject
>
parseArrayTag
>
parseXMLElement
>
getContentObject
>
parseDictTag
>
parseXMLElement
>
getContentObject
>
parseDictTag
>
parseXMLElement
>
getContentObject
>
parseDictTag
>
parseXMLElement
>
getContentObject
>
parsePListTag
>
parseXMLElement
>
parseXMLPropertyList
>
_CFPropertyListCreateFromXMLData
>
_loadXMLDomainIfStale
>
fetchXMLValue
>
_CFPreferencesDomainCreateValueForKey
>
CFPreferencesCopyValue
>
GetDevicePList
>
GetNextDeviceList
>
GetDefaultDeviceDict
>
CMGetDefaultDevice
>
CMGetDeviceTrackingByUse
>
CMGetDefaultProfileByUse
>
PJCCopyColorSyncSystemProfilePath
>
PJCDefaultPrintSettings
>
PMSessionDefaultPrintSettings
>
-[NSPrintInfo _initPrivData]
>
-[NSPrintInfo _initWithDictionary:pageFormat:printSettings:]
>
-[NSPrintInfo copyWithZone:]
>
-[NSConcretePrintOperation initWithView:printInfo:]
>
-[NSConcretePrintOperation
>
initEPSOperationWithView:insideRect:toData:printInfo:]
>
+[NSConcretePrintOperation PDFOperationWithView:insideRect:toData:printInfo:]
>
+[NSConcretePrintOperation PDFOperationWithView:insideRect:toData:]
>
+[NSPrintOperation PDFOperationWithView:insideRect:toData:]
>
-[NSView(NSPrinting) dataWithPDFInsideRect:]
>
>
Any more ideas?
>
>
Thanks, - Peter
>
>
-
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes gar anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.