-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Angular-Slickgrid is causing a memory leak in my application #610
Comments
You can try destroying the component by using angularGridReady(angularGrid: AngularGridInstance) {
this.angularGrid = angularGrid;
}
ngOnDestroy() {
this.angularGrid.destroy();
} I have never used this memory tab in Chrome and never knew how to use it (but I never looked for it either). I added the |
Thank you so much for your quick response. Unfortunately, that doesn't fix the problem. It's interesting though, as you pointed out and I ran some tests on my end as well, the GridClientSideComponent always stays one instance, so I'm trying to figure out what can be the line of code that sets this component apart from the others, tried a couple of things but no dice yet. Thank you so much! |
Hmm looking at some Services, there a few |
- causes memory heap size to keep growing
I made some changes to make sure to unsubscribe by using I see that the heap size stays about the same now, not sure if that's a valid test, here's what it looks like after toggling about 10x times back and forth between some of the Examples Actually this is probably not a good test since the GitHub Demo seems to be behave the same way. |
Thank you, much appreciated!! It's still a problem though, and looking at the code I can see that there are still a bunch of subscribe calls that the return value is not assigned to any variable, which means it cannot be unsubscribed from such as this in grid-frozen:
. Also are you sure that complete does the job? From the little research that I did it seems like complete will make sure to complete the event handler, but it will continue to listen to future events. |
No I'm not sure for I would prefer if you have time to look at the code and find the ones that are unsubscribe and possibly do a PR. I actually haven't in couple months, working on something else for now. It's possible that a few Examples are missing unsubscribed, that Frozen one you said is missing it and should be updated with ngOnDestroy() {
this.gridObj.onMouseEnter.unsubscribe();
this.gridObj.onMouseLeave.unsubscribe();
} |
Yes, will do, thanks again! |
I could be wrong but aren't suppose to unsubscribe only something we subscribed to? Those subscriptions should be handled already, at least for the most part. I might have misunderstood how RxJS works though, so any PR is welcome. |
I hear, I'm not sure. The fact is that those are the only ones left, that are not unsubscribed from, and it's still leaking, so I'm hoping that will fix it...we'll see |
* fix(core): unsubscribe every possible events #610 - causes memory heap size to keep growing * refactor: use subscriptions array instead of single subscription * fix: remove keydown binding when disposing of externalCopy plugin * fix: possible leak, body onClick event not unbound in multiple-select
From your last comment I can assume that we can now close the issue 🚀 👾 You can also upvote if you haven't already ⭐ |
Yes! ☺
|
I'm submitting a Bug report
Your Environment
Describe the Bug
It's been a couple of days that I'm trying to figure out why certain aspects of my angular application are slow. After much hassle I finally figure out that my destroyed components are not getting unloaded from memory. I use the memory tab in chrome tools, I take a snapshot of the heap and all my components are times the amount of time I switched between views, which is a big problem because this slows down the application a lot.
So I decided I'm going to take out most of the code and just have the skeleton of the components and have the ability to route between them and I kept removing code until the problem was gone. It turns out that as long as I don't add angular slick grid to my html component I'm fine. As soon as I add it, this problem happens.
It usually means that you might have even listeners that are still open, or something like that, that's preventing the GC to unload them from memory.
As a matter of fact I downloaded the Angular-Slickgrid project and ran the examples locally, and than ran the same memory test. And sure enough same problem the components keep piling up as I switch between them.
The strange thing is that if I compile Angular-Slickgrid in prod mode, I don't see any components in the heap (meaning to say I don't see any objects that end with the word component) nor do I see any objects that resemble the components in examples, why is that? The only thing I can find is SlickGrid and every click adds another instance in prod build as well.
If you can shed some light into this would be very much appreciated, I'm at loss what to do next.
Steps to Reproduce
as mentioned above just run the examples, keep toggling between components a couple of times. Then hit F12 to bring up Chrome Dev Tools, go to the memory tab, in the Heap snapshot option there's a Take snapshot button, hit that. Once the snapshot is loaded, you can filter by component, and you'll see that
Expected Behavior
Destroyed components should be garbage collected and should not persist in memory.
Current Behavior
Components are not being removed from the heap.
Possible Solution
Code Sample
The Angular-Slickgrid sample shows this problem
The text was updated successfully, but these errors were encountered: