Implement -reclaimMemory API and switch to manually controlled content clearing.

ASDisplayNode and several subclasses had previously cleared memory-heavy
objects like the backing store and text layout manager when the node's
view
or layer is removed from a visible heirarchy.  This works great in any
system
that uses a "working range", where exiting the range removes the node
from
the hierarchy and reclaiming memory at that time is important.
However, for
standard UIViewController patterns (unused in Paper), this behavior
causes
highly undesirable thrashing (leading to visible flashes & wasteful
re-rendering of content).

After this change, node subclasses should implement -reclaimMemory if
they
need to perform any other cleanup besides backing store destruction
when they
leave a working range or other scenario where memory reduction is
valuable.

To trigger this behavior, calling code should use
-recursivelyReclaimMemory.

r=nadi
This commit is contained in:
Scott Goodson
2014-10-14 18:35:11 -07:00
parent 6a1854ed6a
commit f7d91bb877
9 changed files with 76 additions and 70 deletions

View File

@@ -322,6 +322,19 @@
*/
- (void)recursiveSetPreventOrCancelDisplay:(BOOL)flag;
/**
* @abstract Calls -reclaimMemory on the receiver and its subnode hierarchy.
*
* @discussion Clears backing stores and other memory-intensive intermediates.
* If the node is removed from a visible hierarchy and then re-added, it will automatically trigger a new asynchronous display,
* as long as preventOrCancelDisplay is not set.
* If the node remains in the hierarchy throughout, -setNeedsDisplay is required to trigger a new asynchronous display.
*
* @see preventOrCancelDisplay and setNeedsDisplay
*/
- (void)recursivelyReclaimMemory;
/** @name Hit Testing */