addEventListener with anonymouse method -- memory leak?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

addEventListener with anonymouse method -- memory leak?

Mihail Ivanchev
Hi guys,

How dangerous is

obj.addEventListener(event, function (e) { ... });

will this create a memory leak when I assign obj = null or is haXe smart enough to reclaim it.

Cheers!

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: addEventListener with anonymouse method -- memory leak?

Baluta Cristian
Nope, will remain somewhere floating. You can easily test with enter_frame

Baluta Cristian
http://imagin.ro

On 15.10.2011, at 13:09, Mihail Ivanchev <[hidden email]> wrote:

> Hi guys,
>
> How dangerous is
>
> obj.addEventListener(event, function (e) { ... });
>
> will this create a memory leak when I assign obj = null or is haXe smart enough to reclaim it.
>
> Cheers!
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: addEventListener with anonymouse method -- memory leak?

Pimm Hogeling
I don't think you can test this using Event.ENTER_FRAME.

Event.ENTER_FRAME should only be dispatched by objects that are in the display tree (for as far as I remember). You'd have to add obj to the display tree. Once you do, you cannot lose all references to it by using obj = null; You'd have to call removeChild as well, which - in turn - will prevent it from dispatching Event.ENTER_FRAME

Please correct me .

2011/10/15 Baluta Cristian <[hidden email]>
Nope, will remain somewhere floating. You can easily test with enter_frame

Baluta Cristian
http://imagin.ro

On 15.10.2011, at 13:09, Mihail Ivanchev <[hidden email]> wrote:

> Hi guys,
>
> How dangerous is
>
> obj.addEventListener(event, function (e) { ... });
>
> will this create a memory leak when I assign obj = null or is haXe smart enough to reclaim it.
>
> Cheers!
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: addEventListener with anonymouse method -- memory leak?

Baluta Cristian
The event is dispatched even if the object is not in the display tree, that's how some tween engines are made, and i tested before answering anyway.

Baluta Cristian

On 15.10.2011, at 13:46, Pimm Hogeling <[hidden email]> wrote:

I don't think you can test this using Event.ENTER_FRAME.

Event.ENTER_FRAME should only be dispatched by objects that are in the display tree (for as far as I remember). You'd have to add obj to the display tree. Once you do, you cannot lose all references to it by using obj = null; You'd have to call removeChild as well, which - in turn - will prevent it from dispatching Event.ENTER_FRAME

Please correct me <330.gif>.

2011/10/15 Baluta Cristian <[hidden email]>
Nope, will remain somewhere floating. You can easily test with enter_frame

Baluta Cristian
http://imagin.ro

On 15.10.2011, at 13:09, Mihail Ivanchev <[hidden email]> wrote:

> Hi guys,
>
> How dangerous is
>
> obj.addEventListener(event, function (e) { ... });
>
> will this create a memory leak when I assign obj = null or is haXe smart enough to reclaim it.
>
> Cheers!
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org