Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

官方示例中的vue写法存在内存泄漏 #674

Closed
zczhangchao51 opened this issue Jun 17, 2020 · 1 comment · Fixed by #675
Closed

官方示例中的vue写法存在内存泄漏 #674

zczhangchao51 opened this issue Jun 17, 2020 · 1 comment · Fixed by #675

Comments

@zczhangchao51
Copy link
Contributor

zczhangchao51 commented Jun 17, 2020

What happens?

官方示例中的vue写法存在内存泄漏

Mini Showcase Repository(REQUIRED)

官方示例

How To Reproduce

  1. 首先在官方示例的vue子项目的Home.vue的data加入一个占用比较多内存的变量(方便放大影响)
data() {
      return {
+        leak: new Array(5 * 1024 * 1024),
        dialogVisible: false,
      };
    },
  1. 开启无痕模式进行内存记录,然后不断的切换不同的子项目

  2. 结果显示vue的实例并没有释放

image

解决方式

虽然qiankun代码中会删除这些vue实例的html节点,但是不知道什么原因�这些html对应的内存并没有释放

通过在unmount中设置清除html节点可解决此问题

export async function unmount() {
  instance.$destroy();
+  instance.$el.innerHTML = "";
  instance = null;
  router = null;
}

参考: https://github.com/single-spa/single-spa-vue/blob/adc35a667b18ea8acd87b352739d78b771cddb38/src/single-spa-vue.js#L145

image

Context

  • qiankun Version: 2.x
  • Platform Version: mac
  • Browser Version: chrome
@zczhangchao51
Copy link
Contributor Author

#675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants