A "delete" doesn't free the memory. It just remove any reference stored in the variable.

I.e. :

var x = "fffffuuuu" /* Allocate the string in the heap and store its reference in x */ delete x; /* Remove the reference to the string but DOESN'T free the memory */ [...] Garbage collection release the memory of any unrefenced memory address. (This can happen 10min later).


Le 25/01/11 00:12, Nicolas a écrit :
I think that have found my memory leak (hopefully no more, fingers
crossed).

Actually, there was indeed something wrong around the delete keyword.

delete works fine actually. However, I was doing this:

1) declaring a global array: matches=new Array();

2) in function 1, I was doing:
mc=...
matches[mc]=new match(....);
do a few things
call end_match(matches[mc]);

3) in end_match(g) function, I had:
delete(g)

And that's this delete(g) that was doing nothing.

I still don't know enough about this to understand fully. Maybe
someone can explain that to me. I see no good reason why g (pointing
to my object in the array) should not be deleted. I guess it has to do
with the scope of g (the GC only deletes the "pointer" not what it
points to). But I am not sure of that. There might be more obscure
reasons.

In any case, that was a tricky one.

I hope it will help someone.

Thanks all for your time, and maybe you can tell me why it behaves
like this.

Nicolas.



On 24 jan, 21:10, Johnathan Leppert<[email protected]>
wrote:
Instead of delete, have you tried setting the reference to the class to
null?

On Sun, Jan 23, 2011 at 5:24 PM, Nicolas<[email protected]>  wrote:
Hi,
Test loading my app on the server side, I realized that I had a big
memory leak.
Narrowing down the problem, I ended up load testing something really
simple, with still a memory leak:
                            var i_max=50000;
                            mc=0;
                            for (var i=1;i<=i_max;i++)
                            {
                                matches[i]=new Test_Class("s",
1,mc,"local",0,0,1);
                                delete (matches[i]); // Never does
anything... There does not seem to be any destructor in Mootools.
                            }
With the empty class Test_Class defined like this:
Test_Class= new Class({
        //Constructor
        initialize: function(param1, param2, param3, )
        {
        }
});
The 50,000 iterations lead to a leak of 40 Mb, that is 0.8kB per new
object of the class created.
I have Mootools 1.2.4 on the server, with a compile from the git from
the 16th of december.
My questions are:
1) Do you think that the memory leak is related to SpiderMonkey or
Mootools?
2) Do you think upgrading to Mootools 1.3 help? I have tried but
failed to do so. For some reasons, I don't manage to make it work.
3) Can you reproduce the problem on you server? It should not take
very long to copy the few lines above.
4) Are there any know memory leak left in Ape?
Any help greatly appreciated.
Thanks in advance.
Nicolas.
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]<ape-project%[email protected]>
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website :http://www.ape-project.org/
Git Hub :http://github.com/APE-Project/

--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to