Movie clip never garbage collected

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

Movie clip never garbage collected

Bilboon
Hi,

I have a weird trouble with a movie clip that are not garbage collected. I have not added listeners to it.

My smallest use case is :

-----------------------------------------

- create 2 movie clips in flash :
1) 1 frame movie clip linked as MCTest
2) 2 frames movie clip linked as MCAnimation. First frame contains an instance of MCTest.

- include swf in haxe with -swf-lib option

- define MCAnimation and MCTest in haxe:

class MCAnimation extends flash.display.MovieClip{
}

class MCTest extends flash.display.MovieClip{
    function new(){
        super();
        trace("init");
    }
}

- define main static function :

import MCTest;
class Main{
    static function main(){
        var a = new MCAnimation();
    }
}

- compile haxe to flash 9 target.

-----------------------------------------

The result is a infinite trace "init". I think it's because, MCAnimation is running in background, so each frame it creates a new MCTest. I dont understand this strange behavior, i tried to create dummy object to fill RAM and force gc without success. Is it a bug, i miss something ? Help will be appreciated.

PS : full sources are joined.


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

test.tgz (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Movie clip never garbage collected

jlm@justinfront.net
Maybe you need a stop(); on the second frame so that it does not  
automatically go back to the first frame.

Cheers ;j

On 12 Mar 2010, at 12:07, Bilboon wrote:

> Hi,
>
> I have a weird trouble with a movie clip that are not garbage  
> collected. I have not added listeners to it.
>
> My smallest use case is :
>
> -----------------------------------------
>
> - create 2 movie clips in flash :
> 1) 1 frame movie clip linked as MCTest
> 2) 2 frames movie clip linked as MCAnimation. First frame contains  
> an instance of MCTest.
>
> - include swf in haxe with -swf-lib option
>
> - define MCAnimation and MCTest in haxe:
>
> class MCAnimation extends flash.display.MovieClip{
> }
>
> class MCTest extends flash.display.MovieClip{
>     function new(){
>         super();
>         trace("init");
>     }
> }
>
> - define main static function :
>
> import MCTest;
> class Main{
>     static function main(){
>         var a = new MCAnimation();
>     }
> }
>
> - compile haxe to flash 9 target.
>
> -----------------------------------------
>
> The result is a infinite trace "init". I think it's because,  
> MCAnimation is running in background, so each frame it creates a new  
> MCTest. I dont understand this strange behavior, i tried to create  
> dummy object to fill RAM and force gc without success. Is it a bug,  
> i miss something ? Help will be appreciated.
>
> PS : full sources are joined.
>
> <test.tgz>--
> 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: Movie clip never garbage collected

Bilboon
Ok but why the mc is not GC ? Are the movie clip garbage collected only when they are stopped ?

2010/3/12 Justin Lawerance Mills <[hidden email]>
Maybe you need a stop(); on the second frame so that it does not automatically go back to the first frame.

Cheers ;j


On 12 Mar 2010, at 12:07, Bilboon wrote:

Hi,

I have a weird trouble with a movie clip that are not garbage collected. I have not added listeners to it.

My smallest use case is :

-----------------------------------------

- create 2 movie clips in flash :
1) 1 frame movie clip linked as MCTest
2) 2 frames movie clip linked as MCAnimation. First frame contains an instance of MCTest.

- include swf in haxe with -swf-lib option

- define MCAnimation and MCTest in haxe:

class MCAnimation extends flash.display.MovieClip{
}

class MCTest extends flash.display.MovieClip{
   function new(){
       super();
       trace("init");
   }
}

- define main static function :

import MCTest;
class Main{
   static function main(){
       var a = new MCAnimation();
   }
}

- compile haxe to flash 9 target.

-----------------------------------------

The result is a infinite trace "init". I think it's because, MCAnimation is running in background, so each frame it creates a new MCTest. I dont understand this strange behavior, i tried to create dummy object to fill RAM and force gc without success. Is it a bug, i miss something ? Help will be appreciated.

PS : full sources are joined.

<test.tgz>--
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: Movie clip never garbage collected

tom rhodes
if it's looping through the frames it'll keep on being created on frame one...


On 12 March 2010 13:16, Bilboon <[hidden email]> wrote:
Ok but why the mc is not GC ? Are the movie clip garbage collected only when they are stopped ?

2010/3/12 Justin Lawerance Mills <[hidden email]>

Maybe you need a stop(); on the second frame so that it does not automatically go back to the first frame.

Cheers ;j


On 12 Mar 2010, at 12:07, Bilboon wrote:

Hi,

I have a weird trouble with a movie clip that are not garbage collected. I have not added listeners to it.

My smallest use case is :

-----------------------------------------

- create 2 movie clips in flash :
1) 1 frame movie clip linked as MCTest
2) 2 frames movie clip linked as MCAnimation. First frame contains an instance of MCTest.

- include swf in haxe with -swf-lib option

- define MCAnimation and MCTest in haxe:

class MCAnimation extends flash.display.MovieClip{
}

class MCTest extends flash.display.MovieClip{
   function new(){
       super();
       trace("init");
   }
}

- define main static function :

import MCTest;
class Main{
   static function main(){
       var a = new MCAnimation();
   }
}

- compile haxe to flash 9 target.

-----------------------------------------

The result is a infinite trace "init". I think it's because, MCAnimation is running in background, so each frame it creates a new MCTest. I dont understand this strange behavior, i tried to create dummy object to fill RAM and force gc without success. Is it a bug, i miss something ? Help will be appreciated.

PS : full sources are joined.

<test.tgz>--
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
Reply | Threaded
Open this post in threaded view
|

Re: Movie clip never garbage collected

clemos
In reply to this post by Bilboon
Hi

I think it has nothing to do with GC.
It's just that your main movie loops through its 2 frames.
At every iteration, your MCTest instance is created on the stage in
frame 1, then destroyed in frame 2 (and so probably GC-ed), and then
re-created on frame 1 and so on.

It's your frame 2 which should contain a "stop()", not your MCTest.

+++++++
Clément

On Fri, Mar 12, 2010 at 1:16 PM, Bilboon <[hidden email]> wrote:

> Ok but why the mc is not GC ? Are the movie clip garbage collected only when
> they are stopped ?
>
> 2010/3/12 Justin Lawerance Mills <[hidden email]>
>>
>> Maybe you need a stop(); on the second frame so that it does not
>> automatically go back to the first frame.
>>
>> Cheers ;j
>>
>> On 12 Mar 2010, at 12:07, Bilboon wrote:
>>
>>> Hi,
>>>
>>> I have a weird trouble with a movie clip that are not garbage collected.
>>> I have not added listeners to it.
>>>
>>> My smallest use case is :
>>>
>>> -----------------------------------------
>>>
>>> - create 2 movie clips in flash :
>>> 1) 1 frame movie clip linked as MCTest
>>> 2) 2 frames movie clip linked as MCAnimation. First frame contains an
>>> instance of MCTest.
>>>
>>> - include swf in haxe with -swf-lib option
>>>
>>> - define MCAnimation and MCTest in haxe:
>>>
>>> class MCAnimation extends flash.display.MovieClip{
>>> }
>>>
>>> class MCTest extends flash.display.MovieClip{
>>>    function new(){
>>>        super();
>>>        trace("init");
>>>    }
>>> }
>>>
>>> - define main static function :
>>>
>>> import MCTest;
>>> class Main{
>>>    static function main(){
>>>        var a = new MCAnimation();
>>>    }
>>> }
>>>
>>> - compile haxe to flash 9 target.
>>>
>>> -----------------------------------------
>>>
>>> The result is a infinite trace "init". I think it's because, MCAnimation
>>> is running in background, so each frame it creates a new MCTest. I dont
>>> understand this strange behavior, i tried to create dummy object to fill RAM
>>> and force gc without success. Is it a bug, i miss something ? Help will be
>>> appreciated.
>>>
>>> PS : full sources are joined.
>>>
>>> <test.tgz>--
>>> 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
Reply | Threaded
Open this post in threaded view
|

Re: Movie clip never garbage collected

Bilboon
Ok i understand but the main function is executed one time, the MCAnimation is not the main movie, it's not added to stage and no reference is kept on it. I made assumptions that it would be garbage collected ?

But thx a lot for the tip Justin, i found same suggestions here : http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html

May be running mc have listeners added to them that stops GC ?


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

Re: Movie clip never garbage collected

jlm@justinfront.net
If your putting code in frames then the code will be there to run again next time the frame is visited

On 12 Mar 2010, at 12:43, Bilboon wrote:

Ok i understand but the main function is executed one time, the MCAnimation is not the main movie, it's not added to stage and no reference is kept on it. I made assumptions that it would be garbage collected ?

But thx a lot for the tip Justin, i found same suggestions here : http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html

May be running mc have listeners added to them that stops GC ?

--
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: Movie clip never garbage collected

Bilboon
May be i miss something. For me the first frame of animation should not be revisited because the MCAnimation was not added to stage and was only present in init of the app.

But, sorry for the noise, i made some new tests, and it seems i'm wrong about the GC, i changed the main file with :

import flash.system.System;
class Test{

    static function main(){
        var timer = new haxe.Timer(100);
        timer.run = testGC;
    }

    static function testGC(){
        trace(System.totalMemory);
        for (i in 0...1000){
            var a = new MCAnimation();
            //a.stop();
        }
       
    }
}

...and the GC seems effective. The MCAnimation instances are garbage collected when player reaches 100Mo. Interesting thing is with the stop instruction : player never reach more than 25Mo.


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