Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can ASDisplayNode "unload" its lazy properties under memory pressure? #1505

Open
bolsinga opened this issue May 9, 2019 · 2 comments
Open

Comments

@bolsinga
Copy link
Contributor

bolsinga commented May 9, 2019

Can ASDisplayNode "unload" its lazy properties under memory pressure?

Some things are lazily initialized in ASDisplayNode. Can these things be nil-ed out under memory pressure? I see a -clearContents method. Is it possible to call something like that on "all the not really visible nodes" when there is memory pressure?

@nguyenhuy @garrettmoon @appleguy @Adlai-Holler @maicki

@Adlai-Holler
Copy link
Member

Good question, and yes we do that. When there is a memory warning, all the range controllers in the app shrink their display ranges down to the visible area (rangeMode.) When a node exits the display range, its clearContents is called. Additionally, there is the concept of “visibility depth” for view controllers, which shrinks the display range of view controllers based on how far away they are from visible (say, in a navigation controller.)

clearContents refers specifically to “CALayer.contents,” not to arbitrary preloaded data which should be cleared when a node exits the preload range.

One interesting option, though, is to change the driving event for range controllers from UIApplication memory warnings, to the different warning levels of DISPATCH_SOURCETYPE_MEMORY_WARNING to go even further at the critical level.

BTW I’ve heard about your past work on iPhone, glad to have you working on memory consumption, happy to be a sounding board for any ideas that arise.

@bolsinga
Copy link
Contributor Author

bolsinga commented May 9, 2019

These will all help. With Pinterest interested in memory reduction, getting a design in Texture that does not have unbounded memory accumulation as a side effect will be terrific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants