mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
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:
@@ -179,6 +179,7 @@
|
||||
* @discussion Subclasses should override this if they don't want their contentsScale changed.
|
||||
*
|
||||
* @note This changes an internal property.
|
||||
* -setNeedsDisplay is also available to trigger display without changing contentsScaleForDisplay.
|
||||
* @see contentsScaleForDisplay
|
||||
*/
|
||||
- (void)setNeedsDisplayAtScale:(CGFloat)contentsScale;
|
||||
@@ -271,6 +272,11 @@
|
||||
// Called after the view is removed from the window.
|
||||
- (void)didExitHierarchy;
|
||||
|
||||
// Called by -recursivelyReclaimMemory. Provides an opportunity to clear backing store and other memory-intensive intermediates,
|
||||
// such as text layout managers or downloaded content that can be written to a disk cache.
|
||||
// Base class implements self.contents = nil, clearing any backing store, for asynchronous regeneration when needed.
|
||||
- (void)reclaimMemory;
|
||||
|
||||
|
||||
/** @name Description */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user