Static GitHub Issues

[805] Analyze possible memory leaks

prev: middleware not rendered on the client
next: i have exclude node_modules,but not exclude vendor

As of some users are reporting memory leaks in their production environment, I've opened this issue trying to help investigate (possible?) memory leaks causing from Nuxt or SSR engine of vue.js. We may resolve problems before stable 1.0.0 release, but it needs users contribution to help to test different conditions and to provide reports & heap dumps. (Related to #678 #661 #658 #1695)

Testing Environment

It may be better to create a new and clean repository to prevent side-effects of using third-party plugins such as lodash. (they may have memory leaks too)

  • Important Using latest nuxt.js (1.0.0-rc*) because it is using runInNewContext:false SSR options.
  • Using latest stable node.js release, either 6.10.3 LTS or 8.x (recommended)
  • Recommended using docker isolated containers to prevent side effects of other processes.
  • Important Use nuxt build, nuxt start and not nuxt dev. We are analyzing production environments.
  • Recommended using yarn instead of npm to ensure exact dependencies are installed.

Testing Procedure

The article finding-a-memory-leak-in-node-js may help a lot to take offline heap snapshots. Below is a suggested approach for that. If you are using nuxt programmatically (in express for example) you may take another approach.

In nuxt.config.js before module.exports:

  • Add heapdump = require('heapdump');
  • Add a setInterval to periodically (~15min) take snapshots

You can use tools like ab to emulate light request traffic on the web server.

Meanwhile, you may also track memory allocation using any tool you want. It is recommended to keep the server running for more than 1 hour.

Important Please notice about garbage collection. Don't try to emulate high memory usage by applying heavy load on SSR engine it may give false positive memory leaks and performance downsides. If actually memory leak exists it may happen even with the normal amount of requests/load.

Reports

After tests done, you may personally analyze and compare heap dumps using chrome dev tools. Also providing a report in this thread would be so nice. Please at least include following details:

  • Source code repository to reproduce
  • Mention If any used third-party plugin or framework
  • Testing environment specs
    • OS
    • Server Resources
    • Exact version of running nuxt and node.js
  • Heap dump analyzes results / raw files. (2 files maximum)
  • Screenshots of memory usage over time
  • Other special notes
  • Possible leak source
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c689">#c689</a>)</em></sub></div>