Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Memory leaks #142

Open
TunaYagci opened this issue Aug 13, 2018 · 7 comments
Open

Memory leaks #142

TunaYagci opened this issue Aug 13, 2018 · 7 comments

Comments

@TunaYagci
Copy link

This component is leaking and it's heavily affecting us in production. I can provide a jsFiddle if you need it.

@kenberkeley
Copy link
Collaborator

hope to see your jsfiddle demo

@TunaYagci
Copy link
Author

@kenberkeley fiddle here: https://jsfiddle.net/TunaYagci/eywraw8t/272323/

My usual memleak routine:
(You'll need Chrome debugger)

  1. Click /home
  2. Snapshot
  3. Click /foo
  4. Click /home
  5. Snapshot
  6. Compare these snapshosts

Normally, when you route back you should see the VueComponent delta must be 0 (test it with route /boo, you'll see the difference=0)

Difference after /home -> /foo -> /home (~13 components are not deleted)
screen shot 2018-08-15 at 18 22 01

Do that /home -> /foo -> /home for x20 times (~200 components are not deleted)
As you can see even snapshot size is increased as 3mb (this is huge in production because when it leaks, it leaks with whole component tree with it):
screen shot 2018-08-15 at 18 23 17

Reason why I'm testing this with vue-router is that leaks are simple and visible here. Unless you called keep-alive these components should've been deleted.

@mhascak
Copy link

mhascak commented Sep 11, 2018

Hi, any progress ?

@kenberkeley
Copy link
Collaborator

no idea😂

@mhascak
Copy link

mhascak commented Sep 21, 2018

I fixed some memory leaks, they were caused moustly by unregistered jQuery events.
mhascak@76129de

@TunaYagci
Copy link
Author

TunaYagci commented Oct 3, 2018

@Klainer can you share a release so I can test it on jsFiddle?
Never mind I've just seen your commit had it.

@TunaYagci TunaYagci reopened this Oct 3, 2018
@TunaYagci
Copy link
Author

TunaYagci commented Oct 3, 2018

@Klainer that commit really did something. Here are the results:
Before:
screen shot 2018-10-03 at 11 36 02

After:
screen shot 2018-10-03 at 11 35 55

So if you look at VueComponent, this commit really cleaned up the leaks. 🎉 🎉

But, I don't know why Vue constructors are still here. There seems to be another leak somewhere, but I'm not sure. This usually happens when you call new Vue() (usually for an eventBus) and didn't stop listening it on beforeDestroyed. You have to call eventBus.$off, like this:

created(){
    this.eventBus.$on('content-type-saving', this.listener)
  },
  beforeDestroy(){
    this.eventBus.$off('content-type-saving', this.listener)
  }

Nice work, really 👍 Just wondering, how did you catch those leaks?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants