[KONQ_E_1_0_BRANCH] Javascript memory leak partially resolved
Simon Hausmann
konq-e@mail.kde.org
Wed, 15 Jan 2003 17:27:29 +0100
On Wed, Jan 15, 2003 at 04:41:33PM +0100, Luciano Montanaro wrote:
Content-Description: clearsigned data
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Some time ago, there was a discussion about a snippet of javascript similar to
> this one:
>
> //------------
> // this script demonstrates the memory leak bug.
> // The bigstr string should eat around
> // 10*2^18 ~ 2.5MB, rally eats ~ 5MB; 10*2^20 ~ 10MB, eats ~ 20MB
>
> var bigstr = "0123456789";
>
> for (i = 0; i < 20; i++) {
> bigstr += bigstr;
> }
> debug("String length = " + bigstr.length);
> //------------
>
> That allocated twice the memory it really needs.
>
> I searched the kde-cvs list for leak related fixes in CVS, and found
> one change that could solve the problem. The change is pretty simple and
> seemingli innocuous, but running the above program I get
> 49 objects still allocated at the end of the program, and a core file
> of ~1.5M against one of 40M, so the patch seems effective.
>
> The remaining allocated objects seem to be allocated during the GlobalObject
> initialization.
>
> I'll look for those later.
>
> I'd like advice on this patch: do you think it's useful enough to ask for
> inclusion on the KDE2.2 branch for use by kdenox?
I doubt it has a chance for inclusion into the 2.2 branch, but on
the other hand I see no problem with including the patch in konq/e
by applying it at build time. That is, if you feel it is safe
enough. I for one have no objections for including it in konq/e
(trusting you, as I lack knowledge about kjs :)
Simon