Severe JS memory leak - can someone confirm?

Paul Chitescu konq-e@mail.kde.org
Tue, 15 Oct 2002 18:58:49 +0200


Hello!

Can someone confirm the severe Javascript memory leak I've found?

In the process of implementing special host Javascript objects I found that
most (or all?) of the global objects never get destroyed! As I suspected a
bug in my implementation I tried with a normal Javascript string which
didn't got destroyed either.

Code to reproduce bug:

<html><body>
<script language="Javascript"><!--
var bigstr="0123456789";
// 10*2^18 ~ 2.5MB, rally eats ~ 5MB; 10*2^20 ~ 10MB, eats ~ 20MB
for (i=0; i<18; i++) bigstr+=bigstr;
document.write("String length = ",bigstr.length);
// --></script>
</body></html>

Write the code in a .html file and load it in konq-e. Locate the process in
/proc and watch the VmData (or use the "top" program). Press F5 several
times so the document is cleared and reloaded several times. If VmData keeps
growing with about 5MB at every reload the bug is confirmed.

The full Desktop Konqueror works as expected, the memory is used only while
the page is displayed and does not increase when reloading.

May this be related to the "QObject::connect() No such signal
QObject::cleared()' debug message? I think this is caused by the fact we
don't use a proper KHTMLView. The KHTMLPart::clear() gets called but maybe
there are some references left from somewhere else.

--
 Paul Chitescu
 pchitescu@null.ro   http://pchitescu.null.ro/   ICQ:22641673
 Any spammers will be painfully squeezed into /dev/null