Skip to content

Have KFAnimatedImage release frames when app goes to background #2445

@Ceylo

Description

@Ceylo

Hi,

MemoryStorage already does a good job at releasing memory when the app goes to background. I would like KFAnimatedImage to do the same.

At the moment I'm looking at how to reduce memory footprint when app is in background, in order to have the app killed less often in background. What I see is that AnimatedImageView frames takes about 25% of the remaining memory.

Callstack is as follow in Instruments:

  32.81 MB     closure #1 in AnimatedImageView.Animator.prepareFramesAsynchronously()	
  32.81 MB     AnimatedImageView.Animator.setupAnimatedFrames()	
  31.78 MB     AnimatedImageView.Animator.loadFrame(at:)	
  31.48 MB     -[UIImage imageByPreparingForDisplay]	
  31.42 MB     -[_UIImageCGImageContent contentPreparedForDisplay]	
  31.34 MB     -[_UIImageCGImageContent _contentWithCARenderRef]	
  31.32 MB     CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, double)	
  23.76 MB     CA::Render::(anonymous namespace)::create_image_by_rendering(CGImage*, CGColorSpace*, unsigned int, double, CA::Render::ImageCopyType)	
  13.83 MB     CA::Render::aligned_malloc(unsigned long, void**, unsigned long)	
  13.83 MB     mmap	

I'd like this memory to be released, and the frames to be loaded again if the view is visible upon foreground transition.
Currently I'm using Kingfisher 8.6.0 on iOS 26.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions