Tracking down memory leak in Vue.js server-side rendering? Tracking down memory leak in Vue.js server-side rendering? vue.js vue.js

Tracking down memory leak in Vue.js server-side rendering?


I finally tracked this down by switching to a more powerful debugging tool than using heap snapshots alone: LLDB and the llnode plugin. This should be very familiar if you have used Joyent's SmartOS and mdb, and it gives you a lot more data to drill into than the standard heap snapshot.

I used the dumpme node module to trigger a core dump inside my production application (there are other ways of doing this, but I found this easiest).

I then followed the instructions found at https://developer.ibm.com/node/2016/09/27/advances-in-core-dump-debugging-for-node-js/ and started tracing the references to the VueComponents that were being held in memory.

> lldb node -c core(lldb) plugin load ./node_modules/llnode/llnode.so(lldb) v8 findjsobjects(lldb) v8 findjsinstances VueComponent(lldb) v8 inspect ...

In this case, it turned out that there was a recursive setTimeout that was never getting cleared when the component was destroyed, so the reference to the entire application stayed in memory.