Memory Leak on route navigation
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-rc.12
- Nitro Version:
0.6.0
- Package Manager:
npm@7.17.0
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
https://v3.nuxtjs.org/getting-started/introduction
Describe the bug
repeatedly switch tabs from e.g. get started
to guide
and watch the memory increase.
Fresh load
After 30 swaps
Additional context
For bigger pages this results in 100s of leaked MBs within only a handful of route changes which in turn makes switching routes take seconds and is really bad user experience.
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top Results From Across the Web
android - Memory leak with simple activities navigation
I launch my app, and let's say the memory usage is 1.1GB total out of my 2GB total memory. I click on a...
Read more >Memory leak: How to avoid it in Vue js
To open the Chrome Task Manager on Mac, choose Chrome Top Navigation > Window > Task Manager or on Windows, use the Shift+Esc...
Read more >Exiting an Angular Route - How To Prevent Memory Leaks
In this tutorial we are going to learn how we can accidentally creating memory leaks in our application while using the Angular router....
Read more >Optimize memory usage and performance
Prior to 2.14.0, all screens are essentially regular native View in each platform, which will increase memory usage and make the render tree...
Read more >Navigation Memory Leak - AI
I have 120 AI characters in a small, bare bones map. They do not have skeletal meshes and very little other logic.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I often regret interim updates, but - 🤷 - my current hypothesis is that this is an issue with
<Suspense>
+<Transition>
preserving the context in the pending branch, meaning every click handler (for example) preserves a reference to potentially thousands of removed DOM nodes.Having entirely disabled
<NuxtPage>
and<NuxtLayout>
in the Nuxt Movies project, I still get the behaviour with the following template. (If you want to replicate, you will also need to swap out the auto-imports ofuseRoute
anduseRouter
to be fromvue-router
for as pure a Vue experience as possible).https://vuejs.org/guide/built-ins/suspense.html#combining-with-other-components
Removing
<Transition>
, either from the template above, or if usingNuxtPage
, viaapp.pageTransition
andapp.layoutTransition
greatly reduces the issue in my testing (that is, in the Nuxt Movies repro, decreases leak from 1.7Mb per navigation to 70Kb). Nevertheless, there are still some preserved detached DOM nodes from the pending state of<Suspense>
, which suggests that the real core issue here is coming from<Suspense>
.The next step is likely to attempt to reproduce using Vue without Nuxt to confirm my hypothesis.
Possible causes I’ve ruled out:
NuxtLink’s intersection observer implementationNuxtLayoutNuxtPage and page progress hooksuseHeadGotcha, got a pretty tight schedule today unfortunately but should I get to it I’ll post it here. Enjoy family time and the rest of your sunday!