Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > representationUsingType:properties: memory leak?

representationUsingType:properties: memory leak?
Thread Tools
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 12, 2004, 02:48 PM
 
Can someone check for me if using NSBitmapImageRep's

representationUsingType:properties:

leaks really really bad?

My properties are pretty basic:

Code:
[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat:snapShotResolution], NSImageCompressionFactor, NULL];
and I know as soon as I try to do this:

Code:
NSData *data = [rep representationUsingType:NSJPEGFileType properties: properties];
I keep getting new memory allocated that is never reclaimed by the system. Removing that line happens to remove the memory leak as well, so I'm pretty sure something screwy is happening with that method...

Thanks,
Matt Fahrenbacher
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 13, 2004, 12:09 PM
 
Okay, so here's a picture of what OmniObjectMeter is telling me:



If you notice on the left, you'll see 2,359,296 bytes of memory allocated several times - in fact, it's the number of times I've called representationUsingType:properties:

Now when you examine one of those allocations on the right hand side, you'll notice that the leak goes back to another helper method called that I have nothing to do with. So... I am just screwed until Apple fixes the bug, or is there something else I can do?

Thanks,
Matt Fahrenbacher
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 13, 2004, 05:03 PM
 
Unless I'm really confused, there seems to be massive amounts of leaking and undocumented, inconsitent behavior in the Apple image APIs. For example:

+imageRepWithData: in NSBitmapImageRep returns an object that isn't scheduled to be autoreleased! I had to do it manually...

-TIFFRepresentationUsingCompression:factor: in NSImage makes a call to NSBitMapImageRep... which unfortunately allocates some memory which also isn't autoreleased! I'm playing with posers and categories right now to get rid of the leak myself, but this is stupid!

Matt Fahrenbacher
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 13, 2004, 06:59 PM
 
Okay, I've changed my mind - I think there's just a whole lot of caching going on. It is somewhat unnerving to see my memory usage go up so much and then drop dramatically though.

Matt Fahrenbacher
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jun 13, 2004, 10:22 PM
 
Yeah, it really is disconcerting. I think you're correct about the caching, though.
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:35 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2