feat:fix iOS memory leak in debugging

This commit is contained in:
pengfei.zhou
2021-03-04 10:02:29 +08:00
committed by osborn
parent b972cce1cd
commit 627f323ae3
14 changed files with 124 additions and 36 deletions

View File

@@ -101,6 +101,7 @@ - (void)build:(CGSize)size {
- (void)reload:(NSString *)script {
[self.driver destroyContext:self.contextId];
self.rootNode.viewId = nil;
[self.rootNode clearSubModel];
self.script = script;
[self.driver createContext:self.contextId script:script source:self.source];
[self init:self.extra];

View File

@@ -195,4 +195,8 @@ - (void)ensureSyncInMainQueue:(dispatch_block_t)block {
dispatch_async(dispatch_get_main_queue(), block);
}
}
- (void)dealloc {
[self.jsExecutor teardown];
}
@end

View File

@@ -48,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)ensureRunOnJSThread:(dispatch_block_t)block;
- (void)initJSEngine;
- (void)teardown;
@end
NS_ASSUME_NONNULL_END

View File

@@ -101,9 +101,9 @@ - (instancetype)init {
return self;
}
- (void)dealloc {
- (void)teardown {
_destroyed = YES;
};
}
- (void)ensureRunOnJSThread:(dispatch_block_t)block {
if (NSThread.currentThread == _jsThread) {

View File

@@ -181,4 +181,10 @@ - (void)requestLayout {
[node requestLayout];
}
}
- (void)clearSubModel {
[super clearSubModel];
self.childNodes = @[];
self.childViewIds = @[];
}
@end