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

Memory leak caused by component switching #1190

Closed
madogai opened this issue Apr 21, 2021 · 2 comments
Closed

Memory leak caused by component switching #1190

madogai opened this issue Apr 21, 2021 · 2 comments
Labels
help wanted Extra attention is needed Status: PR Welcome Welcome to Pull Request

Comments

@madogai
Copy link

madogai commented Apr 21, 2021

日本人のプロジェクトを理解しており、英語のライティングがあまり堪能ではないため、伝わりやすいよう日本語で記述させていただきます。ご容赦ください。

Module versions (please complete the following information):

  • vue: 2.6.12
  • vue-i18n: 8.24.2

Reproduction Link
状況をわかりやすくするための仮想コードです。
動作しないコードで申し訳ないですが、子コンポーネントを切り替えるようなコードとご理解ください。
https://jsfiddle.net/72dnwcxm/

To Reproduce

  1. i18nタグを含んだシングルファイルコンポーネントを作成
  2. アプリ内でシングルファイルコンポーネントを読み込む
  3. v-ifなどで繰り返し読み込むコンポーネントを切り替える

Expected behavior
メモリリークが発生する

Additional context
ca4e11a
このコミットで追加された以下のコードで、子コンポーネントのインスタンス生成時にthis.$rootにイベントを登録するものの、$rootでbeforeDestroyが走らない状況において子コンポーネントの参照が残り続け、読み込んだコンポーネントがガベージコレクションの対象にならない問題が発生しているようです。

this.$root.$once('hook:beforeDestroy', () => {
  options.i18n.root = null;
  options.i18n.formatter = null;
  options.i18n.fallbackLocale = null;
  options.i18n.formatFallbackMessages = null;
  options.i18n.silentTranslationWarn = null;
  options.i18n.silentFallbackWarn = null;
  options.i18n.pluralizationRules = null;
  options.i18n.preserveDirectiveContent = null;
});

本来であれば修正pull requestを作成すべきだとは思うのですが、vue-i18nの全体像を把握しておらず、検証の時間も取れないためissueのみ作成させていただきます。よろしくお願いします。

@madogai madogai added the Status: Review Needed Request for review comments label Apr 21, 2021
@kazupon
Copy link
Owner

kazupon commented Apr 22, 2021

分かりやすい issue reporting ありがとうございました。
Thank you for your clear issue reporting.

この ca4e11a による、メモリリークを再現させて確認し、対応したいと思います。
We would like to reproduce and confirm the memory leak caused by this ca4e11a, and we would like to do the next action.

@kazupon kazupon added help wanted Extra attention is needed Status: PR Welcome Welcome to Pull Request and removed Status: Review Needed Request for review comments labels Apr 22, 2021
@kazupon
Copy link
Owner

kazupon commented Apr 28, 2021

#1192でrevertしたので、closeします。
#1192 revert and close.

@kazupon kazupon closed this as completed Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Status: PR Welcome Welcome to Pull Request
Projects
None yet
Development

No branches or pull requests

2 participants