lit-translate
lit-translate copied to clipboard
Memory leak
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.
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.