lit-translate icon indicating copy to clipboard operation
lit-translate copied to clipboard

Memory leak

Open justinfagnani opened this issue 6 years ago • 1 comments

Because all Parts are added to a global Map, they will persist forever, even if the template instance that contained the part is no longer rendered. Fixing this likely requires the directive disconnect feature (https://github.com/Polymer/lit-html/issues/283) requested on lit-html, but I wanted to file an issue here to track it.

justinfagnani avatar Feb 01 '19 22:02 justinfagnani

I did implement a cleanup functionality that is run every minute when idle to avoid memory leaks. It can be found in https://github.com/andreasbm/lit-translate/blob/master/src/lib/cleanup.ts. I just added a test case for it in #5. You might be able to tell me if I am missing something here, but from my tests this avoids memory leaks. This was the best solution I was able to come up with and it will be obsolete when it is possible to add cleanup logic in directives.

andreasbm avatar Feb 02 '19 12:02 andreasbm