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

fix: lower memory usage #1677

Merged

Conversation

BobbieGoede
Copy link
Member

@BobbieGoede BobbieGoede commented Jan 5, 2024

Not sure if there are downsides to using shallowRef instead of ref only on the server-side. As I understand it there's no reactivity on the server-side, so this shouldn't change much, besides not setting up reactivity tracking for nested keys?

In my testing this fixes the messages from leaking when using computed translations after an async function in Nuxt. I can only guess that the reason for it is that the computed translation is referencing a key inside the object preventing it from being disposed. I don't think this fixes the root cause of the leak in @nuxtjs/i18n, but maybe lowers memory usage overall.

I have also changed the deepCopy function to use iteration instead of recursion, which should lower memory usage as well.

I have tested this with https://github.com/danielroe/i18n-memory-leak with the latest @nuxtjs/i18n and using dependency overrides for vue-i18n and vue-i18n-core with pnpm. I also used a modified locale file to also test nested keys (en.json). Unfortunately I wasn't able to run the e2e tests locally in WSL, I may have better luck on macos but haven't tried yet.

Related

@BobbieGoede BobbieGoede force-pushed the fix/async-context-leaking-messages branch from 46605c5 to e8227ea Compare January 6, 2024 08:51
@BobbieGoede BobbieGoede changed the title fix: locale messages leaking in async context fix: lower memory usage Jan 6, 2024
@kazupon kazupon added the Type: Performance Includes performance fixes label Jan 6, 2024
Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

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

Thanks!
Great works!
It makes sense to use shallowRef on the server side!

@kazupon kazupon merged commit a287a26 into intlify:master Jan 6, 2024
18 checks passed
@kazupon kazupon mentioned this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Performance Includes performance fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants