Hey Quincey, thanks for the reply. You helped me to solve the problem. I was not releasing the arguments of the method (cgImage). I guess because the other variables depend on this one I need to release it first in order to release the rest.
After I added this everything works great! Thanks again and have a nice day :-) Cheers Benedikt On 06.03.2011, at 09:38, Quincey Morris wrote: > On Mar 6, 2011, at 00:19, Benedikt Iltisberger wrote: > >> NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] >> initWithCGImage:cgImage]; >> NSImage *image = [[NSImage alloc] init]; >> [image addRepresentation:bitmapRep]; >> [bitmapRep release]; >> >> LEAK -> [myButton setImage:image]; >> >> [image release]; >> >> I call this every second to update a picture. Everytime I call this the >> memory usage increases by 1MB until the memory is full. > > Why do you think the leak occurs at this line? The memory management of > 'myButton', 'bitmapRep' and 'image' looks correct. It seems more likely the > leak is from 'cgImage' -- where do you CFRelease that? > > The easy way to solve this is to use Instruments (in Xcode, Run->Run with > Performance Tool->Allocations). Then look for 1MB allocations piling up and > see where they're being created. Or use Heapshot to isolate the repeated > allocations. > >> Ok the Outlet is retained but shouldn't cocoa use the same space in memory >> over and over again instead of allocating new space every second? > > The only outlet here is 'myButton', and it is *not* being re-created every > second. A new 'image' is created every second, and that's a new object every > time (along with a new 'bitmapRep', and (presumably) a new 'cgImage'. > > _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
