We have a old large ajax based GUI adapted to MDL. The whole page content is build dynamically (from xml description).
componentHandler.downgradeElements( /all old notes/ ;
remove all old notes form DOM
add new page content to DOM
componentHandler.upgradeAllRegistered();
This works fine, but it leaks memory if the component MaterialLayout
is alos created dynamically .
With the "downgrading fix (#2009" the internal references are removed.
The reason for the memory leak is that the component MaterialLayout
adds a listener to the MediaQueryList (MDL 1.1).
this.screenSizeMediaQuery_.addListener(this.screenSizeHandler_.bind(this));
In MDL 1.1.2 there are two windows event handler added which lead to the same problem.
window.addEventListener('pageshow', function (e) { ... } );
...
window.addEventListener('resize', windowResizeHandler);
This listeners are not removed by downgradeElements
. And therefore the DOM elements are not GC.
Questions:
- Is it not indented to delete the element with
MaterialLayout
? - Is it completely wrong what I doing here?
- Is this an MDL issue?
- Is there a workaround without changing MDL code?