Re: Memory leak in Apple's image handling frameworks ?
Re: Memory leak in Apple's image handling frameworks ?
- Subject: Re: Memory leak in Apple's image handling frameworks ?
- From: Rob Petrovec via Cocoa-dev <email@hidden>
- Date: Sat, 29 Apr 2023 22:13:49 -0600
This sounds like Abandoned Memory, not a leak. Abandoned memory is a retain
cycle somewhere. Best/easiest way to find those is with a memgraph. Click the
little sideways V icon in Xcode’s debugger when the problem is reproducing.
Or run ‘leaks MyApp --outputGraph ~’ in Terminal when the problem is
reproducing and open the resulting .memgraph file in your home directory.
Bonus points is enabling MallocStackLogging in the Xcode Project -> Edit Scheme
-> Run -> Diagnostics and check Malloc Stack Logging and switch to All
Allocations And Free History. This will show backtraces for where an object is
created in the memgraph and other useful info.
Leaks show up as little yellow caution signs and abandoned memory sometimes
have purple caution signs. Either way, look for an abnormally high number of
objects and see if they point back to your image. Thats likely where your
memory is being consumed.
> CGImageSourceCreateWithURL() for loading, CALayer for displaying.
Just a thought since you didn’t mention it: are you releasing the
CGImageSource object too?
Good luck.
—Rob
> On Apr 29, 2023, at 4:07 PM, Gabriel Zachmann via Cocoa-dev
> <email@hidden> wrote:
>
> I have an app that is basically a slide show.
> Basically, it loads one image after another, displays it, then frees up its
> memory.
> When I test it with my image collection of 100k+ images, everything is fine.
>
> However, one user sent me a photo (JPG) that makes my app use up more and
> more memory.
> I can see it in Activity Monitor and in Xcode's Memory Report View.
> After a minute, my app uses 5 GB of main memory, after that, the growth rate
> slows down a bit,
> but it keeps growing without bounds, until, eventually, it crashes, of course.
>
> However, when I try to check for memory leaks using XCode/Instruments/Leaks,
> it says there are none!
>
> Is it possible there is a memory leak in Apple's frameworks?
>
> If you are interested, you can find the image here:
> https://owncloud.informatik.uni-bremen.de/index.php/s/BbBJcjMSTm9enwW
> It's just 5 MB, and I can't see any issue with it.
> The uncompressed image in-memory maybe takes up 100MB.
>
> The frameworks/methods I use are the usual:
> CGImageSourceCreateWithURL() for loading, CALayer for displaying.
>
> I assign the image like this:
>
> CALayer * imgLayer = [CALayer layer];
> imgLayer.contents = (__bridge id)(imageRef);
>
> where imageRef is of type CGImageRef.
> I also release my images later with CGImageRelease().
>
> I am a stymied.
> Any hints/suggestions will be highly appreciated.
>
> Gab.
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden