Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

Fix GC problem - #2797

Open
Gcaufy wants to merge 2 commits into
masterfrom
fix-oom
Open

Fix GC problem#2797
Gcaufy wants to merge 2 commits into
masterfrom
fix-oom

Conversation

@Gcaufy

@Gcaufy Gcaufy commented May 7, 2022

Copy link
Copy Markdown
Collaborator
Checklist
  • npm run test passes
  • tests and/or benchmarks are included
  • cases or donate is changed or added
  • documentation is changed or added

Gcaufy added 2 commits March 31, 2022 13:25
during page navigation, for some reason the page and component instance is not released

re #2712
});
this._watcher.cleanupDeps();
this._watcher.teardown();
this._watchers.forEach(item => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._watchers.slice().forEach,因为 teardown 会从 _watchers 里把自身删掉

let lifecycle = getLifecycycle(WEAPP_COMPONENT_LIFECYCLE, rel, 'component');
output.detached = function(...args) {
let vm = this.$wepy;
vm.$destroy();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个应该在 callUserMethod(vm, vm.$options, 'detached', args); 之后执行吧

Comment on lines +65 to +69
this.$children.forEach(child => {
if (!child._detached) {
child.$destroy();
}
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是没必要,组件自己也是会调用 detached 进行析构的

Comment on lines +79 to +81
delete this._data.__ob__;
delete this._data;
delete this._watcher;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这几个应该都不用删。测了下,删这几个
delete this.$parent; delete this.$root; delete this.$wx.$wepy;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants