Skip to content

严重的内存泄露(memory leak) #2233

@sj-wangchao

Description

@sj-wangchao

Reporting a bug?

以下代码点击开始后,观察“浏览器任务管理器”或“Windows任务管理器”中该标签页的内存占用会明显持续上涨。
使用npm包形式安装也是同样的结果。

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://unpkg.com/vue-i18n@11"></script>

<div id="app">
  <button @click="start">开始</button>
  <button @click="stop">停止</button>
  <div>{{$t('message.hello')}}</div>
  <div>{{$t('message.name')}}</div>
  <div>{{$t('message.city')}}</div>
  <div>{{$t('message.age')}}</div>
  <div>{{$t('message.sex')}}</div>
  <div>{{$t('message.job')}}</div>
  <div>{{$t('message.work')}}</div>
  <div>{{a}}</div>
</div>

<script>
  const { createApp, ref } = Vue

  const zhCn = {
    message: {
      hello: '你好,世界!',
      name: '张三',
      city: '火星',
      age: '十八',
      sex: '男',
      job: '程序员',
      work: '工作'
    }
  }
  const enUs = {
    message: {
      hello: 'Hello, World!',
      name: 'zhang san',
      city: 'mars',
      age: 'eighteen',
      sex: 'man',
      job: 'programmer',
      work: 'work'
    }
  }

  const i18n = VueI18n.createI18n({
    locale: 'zhCn',
    messages:{
      zhCn,
      enUs,
    }
  })

  const app = createApp({
    setup() {
      const a = ref(0);
      let timer;
      function start(){
        timer = setInterval(()=>a.value++,10);
      }
      function stop(){
        clearInterval(timer);
      }
      return {
        a,start,stop
      }
    }
  });
  app.use(i18n);
  app.mount('#app');
</script>

Expected behavior

内存占用不应明显持续上涨

Reproduction

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
    Memory: 15.00 GB / 31.77 GB
  Binaries:
    Node: 22.17.0 - C:\nvm4w\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (138.0.3351.65)
    Internet Explorer: 11.0.19041.5794

Screenshot

  • 刚点击开始按钮时
Image
  • 运行一段时间之后
Image

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions