mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 14:48:25 +00:00
Fabric: Proper handling of memory pressure event in RCTComponentViewRegistry
Summary: View recycling can be pretty aggressive and memory intensive, so we can properly react on system memory-pressure notification. Reviewed By: mdvacca Differential Revision: D13176278 fbshipit-source-id: 38ea1b27da988aeaaa5db6ac0b94389a0bd2799e
This commit is contained in:
parent
cd5f0bd95c
commit
c68e69cb67
@ -81,11 +81,22 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
|
|||||||
_recyclePool = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaquePersonality | NSPointerFunctionsOpaqueMemory
|
_recyclePool = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaquePersonality | NSPointerFunctionsOpaqueMemory
|
||||||
valueOptions:NSPointerFunctionsObjectPersonality];
|
valueOptions:NSPointerFunctionsObjectPersonality];
|
||||||
_componentViewFactory = [RCTComponentViewFactory standardComponentViewFactory];
|
_componentViewFactory = [RCTComponentViewFactory standardComponentViewFactory];
|
||||||
|
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(handleApplicationDidReceiveMemoryWarningNotification)
|
||||||
|
name:UIApplicationDidReceiveMemoryWarningNotification
|
||||||
|
object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
}
|
||||||
|
|
||||||
- (UIView<RCTComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
|
- (UIView<RCTComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
|
||||||
tag:(ReactTag)tag
|
tag:(ReactTag)tag
|
||||||
{
|
{
|
||||||
@ -177,4 +188,9 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
|
|||||||
[componentViews addObject:componentView];
|
[componentViews addObject:componentView];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)handleApplicationDidReceiveMemoryWarningNotification
|
||||||
|
{
|
||||||
|
[_recyclePool removeAllObjects];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user