refactor(mem): 继续优化内存泄漏问题

This commit is contained in:
力皓 2021-04-28 10:03:34 +08:00
parent b65460f029
commit 3853f76ff9
4 changed files with 10 additions and 1 deletions

View File

@ -118,7 +118,6 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
purge() {
this.disposeItems();
this.parent = null as any;
}
// ======= compatibles for vision ======

View File

@ -204,6 +204,7 @@ export class SettingTopEntry implements SettingEntry {
purge() {
this.disposeItems();
this._settingFieldMap = {};
this.emitter.removeAllListeners();
}

View File

@ -770,6 +770,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
this.purged = true;
this.autoruns?.forEach((dispose) => dispose());
this.props.purge();
this.settingEntry.purge();
// this.document.destroyNode(this);
}

View File

@ -4,4 +4,12 @@ if (typeof window !== 'undefined') {
(window as any).SimulatorRenderer = renderer;
}
window.addEventListener('beforeunload', () => {
(window as any).LCSimulatorHost = null;
// @ts-ignore
renderer.dispose?.();
(window as any).SimulatorRenderer = null;
(window as any).ReactDOM.unmountComponentAtNode(document.getElementById('app'));
});
export default renderer;