Paul
Paul

Reputation: 6176

can we know what "eat" the most of memory in a swf ? (flash, as3, monster debugger?)

can we know what "eat" the most of memory in a swf ? is it possible with monster debugger? (i've just downloaded it)

my project works fine, but if i re-launch the swf when it is already launched (cmd+enter -> the swf is launched, then cmd+enter), this seems to give me an example of how it would be if i was on a very very slow computer, and this is "very" slow.

So is there any possiblity to know what i can remove to save the memory?

i use several tweenlite, no sound, and i load all my pages (5) that contains a very basic content, at the beginning, so during the preloading...

thanks for your help ;-)

Cheers

Upvotes: 0

Views: 453

Answers (2)

Ilya Denisov
Ilya Denisov

Reputation: 878

Please be more specific - what do you mean by 'memory'?

I really not expert in Monster Debugger, but it doesn't seems that it have instruments to solve such problems (at least there's no references on website but this one)

For RAM usage statistic you can use FlashDevelop's Debugger (free) as long as Flash Builder's one (you should purchase it if you'll use it but also long-time trial version is available).

But RAM is not the only resource. CPU time is also important (this is the main problem with flash from my point of view). Flash Builder also allow you to profile your performance (to profile - is to get statistic: which functions are called most often, which of them are taking most of the time for execution). Also you could add some code to collect statistic - it's not that hard - just use getTimer() and see the difference before and after some code block (but you have to guess where performance problem could be 'cause it is not that easy to cover you code with measuring manually).

Another think that's should be taken into consideration is swf file size - that affect time it takes to download application before anything happens (loading screen doesn't counts).

Update About removeEventListener. In most cases you should pair every addEventListener with corresponding removeEventListener. Usually I add listeners on ADDED_TO_STAGE and remove them in REMOVED_FROM_STAGE:

function GameObject() // constructor
{
  m_sprite = new MySprite()//...
  // use weak listener (last argument) if there is a way m_sprite will never be attached to stage
  m_sprite.addEventListener( Event.ADDED_TO_STAGE, OnAttached, false, 0, true );
}

private function OnAttached( e:Event ):void
{
  m_sprite.removeEventListener( Event.ADDED_TO_STAGE, OnAttached ) ;
  m_sprite.addEventListener( Event.REMOVED_FROM_STAGE, OnDetached );
  m_sprite.addEventListener( MouseEvent.ROLL_OVER, OnOver );
  m_sprite.addEventListener( MouseEvent.ROLL_OUT, OnOut );
  m_sprite.addEventListener( Event.ENTER_FRAME, OnEnterFrame );
}

private function OnDetached(e:Event):void
{
  m_sprite.removeEventListener( Event.ENTER_FRAME, OnEnterFrame );
  m_sprite.removeEventListener( MouseEvent.ROLL_OUT, OnOut );
  m_sprite.removeEventListener( MouseEvent.ROLL_OVER, OnOver );
  m_sprite.removeEventListener(Event.REMOVED_FROM_STAGE, OnDetached);
  m_sprite.addEventListener( Event.ADDED_TO_STAGE, OnAttached, false, 0, true );
}

Upvotes: 1

user797257
user797257

Reputation:

Usually the tool that analyzes performance is called a "profiler". "Debugger" usually means a program that you use to find errors in code, when it is executed.

Flash player, the debugger version, has API for profiling. There're several front ends to these APIs, one, as Ilya mentioned is in FlashDevelop, there is another one here: http://code.google.com/p/flashpreloadprofiler/ . And, if you really wanted to, you could write one of your own / examine particular parts of your application just as you write the code by using these functions: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/sampler/package-detail.html .

The way you describe how you compile the SWF it sounds like you are using Flash CS# to do that. Flash CS# has it's own debugger (but no profiler). So, if you needed the debugger, it would be worth checking the one that comes with the program, too. IIRC it's Ctrl+Shift+Enter.

Upvotes: 1

Related Questions