Hi Matthew,
Am 01.12.2008 um 16:09 schrieb Matthew Gregory:
> Andreas Junghans wrote:
>> Hi there,
>>
>> Am 01.12.2008 um 14:50 schrieb Matthew Gregory:
>>
>>> You could use "delete this.array" to free the memory instantly, it
>>> is
>>> much slower than assigning it to null and waiting for the GC though.
>>
>> Sorry, but I don't think this is true. "delete this.array" simply
>> removes the "array" key from the associative array that is referenced
>> by "this". It doesn't really "delete" it (as there may be other
>> references to the object), and it's certainly not slower than
>> assigning it to null. (I suppose you didn't really test the
>> performance of "delete". If you did, I'd be interested in the
>> results.)
>
> It was a while ago but I had one test something like this:
>
> var myObj = {};
> var i = 0;
> function doIt()
> {
> myObj[i] = 4;
> delete myObj[i];
> i++;
> }
>
> window.setInterval("doIt()", 10);
>
> and it ran 50 times a second with without eating any memory.
>
> I then tried the same but used "myObj[i] = null" instead of delete and
> it ran roughly 100 times a second but was leaking memory (IIRC about
> 400k a second)
>
> Of course this is with objects not arrays, but I would be suprised if
> the results differed.
I performed some tests using your code, and I can't reproduce your
results in Firefox 3 or IE 7. Setting the references to null should
introduce a small leak (all the keys are still in memory, just
pointing to null), but nothing close to 400k a second.
In my testing, there was no measurable difference in performance or
memory if I let the doIt function run 1000 times.
Firefox 3 (Mac): about 10,3 seconds for 1000 runs, no measurable
impact on memory while running
IE 7 (Win XP, running in VMware): about 15,6 seconds for 1000 runs, no
measurable impact on memory while running
The results were identical for both methods (delete and setting to
null). Which browser did you test in? I would be really surprised to
see the results you mentioned in any non-ancient browser.
Regards,
Andreas
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel