From 05655972e3c6226cf646f0a960961a377bc5ff2e Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 23 Jul 2021 10:03:19 +0800 Subject: [PATCH] iOS:fix memory leak --- doric-iOS/Pod/Classes/DoricSingleton.m | 2 +- .../Pod/Classes/Performance/DoricPerformanceProfile.m | 2 +- doric-js/index.d.ts | 9 +++++++++ doric-js/lib/src/widget/input.d.ts | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doric-iOS/Pod/Classes/DoricSingleton.m b/doric-iOS/Pod/Classes/DoricSingleton.m index f2be2a34..e28616fd 100644 --- a/doric-iOS/Pod/Classes/DoricSingleton.m +++ b/doric-iOS/Pod/Classes/DoricSingleton.m @@ -28,7 +28,7 @@ @implementation DoricSingleton - (instancetype)init { if (self = [super init]) { _libraries = [NSMutableSet new]; - _registries = [NSHashTable new]; + _registries = [NSHashTable weakObjectsHashTable]; _envDic = [NSMutableDictionary new]; _enablePerformance = NO; _enableRecordSnapshot = NO; diff --git a/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m b/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m index 63fbd4d4..1c877133 100644 --- a/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m +++ b/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m @@ -38,7 +38,7 @@ - (instancetype)initWithName:(NSString *)name { _anchorQueue = dispatch_queue_create("doric.performance.profile", DISPATCH_QUEUE_SERIAL); _anchorMap = [NSMutableDictionary new]; _enable = DoricSingleton.instance.enablePerformance; - _hooks = [NSHashTable new]; + _hooks = [NSHashTable weakObjectsHashTable]; } return self; } diff --git a/doric-js/index.d.ts b/doric-js/index.d.ts index 422b1d28..363ab20d 100644 --- a/doric-js/index.d.ts +++ b/doric-js/index.d.ts @@ -795,6 +795,15 @@ declare module 'doric/lib/src/widget/input' { editable?: boolean; returnKeyType?: ReturnKeyType; onSubmitEditing?: (text: string) => void; + /** + * Called before text is changed + * @param editing: text already in box + * @param replacement: text which will replace part of editing + * @param start: the start index of replacing part + * @param length: the length of replacing part + * + * @returns: true means the replacement will take effect, otherwise does not + */ beforeTextChange?: (change: { editing: string; start: number; diff --git a/doric-js/lib/src/widget/input.d.ts b/doric-js/lib/src/widget/input.d.ts index b3177083..d800a986 100644 --- a/doric-js/lib/src/widget/input.d.ts +++ b/doric-js/lib/src/widget/input.d.ts @@ -28,6 +28,15 @@ export declare class Input extends View { editable?: boolean; returnKeyType?: ReturnKeyType; onSubmitEditing?: (text: string) => void; + /** + * Called before text is changed + * @param editing: text already in box + * @param replacement: text which will replace part of editing + * @param start: the start index of replacing part + * @param length: the length of replacing part + * + * @returns: true means the replacement will take effect, otherwise does not + */ beforeTextChange?: (change: { editing: string; start: number;