0

I'm using lit-element (v2.3.1) & lit-html (v1.2.1) and having a memory leak where as a result of rendering, detached DOM nodes are not cleaned by GC and the only retainers shown for them by Chrome DevTools are WeakMaps used internally by lit-html to keep track of parts:

enter image description here

This doesn't happen with all renders, but I have not found a difference between the templates/renders that do and do not leak. Seems almost random. But maybe I'm missing something obvious here, would be glad to hear any suggestions regarding this.

maga
  • 720
  • 3
  • 13
  • Maybe they are elements where you have placed an event listener? – LostInBrittany Jun 24 '20 at 14:40
  • Parents are only listening to events on children by using lit-html's @ syntax to attach the listeners, there are no listeners attached by me through addEventListener or on-. From what I understand about lit-html, detaching parents from DOM should have been enough to allow GC to collect the parents and children. – maga Jun 25 '20 at 11:59

1 Answers1

0

As it happens, there is a known issue with one of the web components I'm using (mwc-ripple) where it attaches event listeners to window and fails to remove them, thus, the browser keeps in memory the whole tree containing the element leading to the memory leak described.

maga
  • 720
  • 3
  • 13