- changed status to resolved
memory leak in dlgMessage(), dlgAlert(), dlgConfirm()
Issue #120
resolved
controls.js functions dlgMessage(), dlgAlert(), dlgConfirm() have a memory leak - they unconditionally create <div> elements attached to the html document that are never deleted. Do we need to create a new <div> for each alert and message? Can we create <div> with fixed id and keep reusing it, like dlgBlackout already does? K.O.
Comments (1)
-
- Log in to comment
Nope. When you close the dialog, dlgMessageDestroy() calls
which removes the <div> from the page. The <div> still exists in memory, but because there is no reference to it any more, it's deleted automatically whey you exit the scope of dlgMessageDestroy(). JavaScript is not C++ and has a different memory model including a garbage collector.
Please read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management for your education.