CALayer leaks with drawRect + keyframe animation + removeFromSuperView
| Originator: | featherless | ||
| Number: | rdar://21760253 | Date Originated: | July 9, 2015 |
| Status: | Open | Resolved: | |
| Product: | iOS | Product Version: | iOS 8, 9 |
| Classification: | Memory leak | Reproducible: | Always |
Summary:
If you add a keyframe animation using addKeyframeWithRelativeStartTime to a UIView that implements drawRect and then immediately remove that view from its superview, memory is leaked proportionally to the size of the view. The memory being leaked follows:
# Address Category Timestamp Live Size Responsible Library Responsible Caller
0 0x10ffbd000 VM: CoreAnimation 00:38.965.672 • 2.93 MB QuartzCore CA::Render::Shmem::new_shmem(unsigned long)
Steps to Reproduce:
While instrumenting for memory allocations:
1. Create a UIView subclass.
2. Implement drawRect: with { [super drawRect:rect]; }
3. Create an instance of the UIView subclass.
3. Within a UIView::animateKeyframesWithDuration animation block, animate the view's alpha within a UIView::addKeyframeWithRelativeStartTime block.
4. Immediately call [view removeFromSuperView];
Expected Results:
Nearly all memory for the view to be released back to the system.
Actual Results:
Memory proportional to the size of the view is leaked permanently.
Version:
iOS 8.3, 8.4, 9.0
Configuration:
iPhone 6, iOS simulator
Example: https://gist.github.com/jverkoey/863ba4df71ca477249a4
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!