我们能知道“吃”什么吗? swf 中的大部分内存? (flash、as3、怪物调试器?)

发布于 2024-12-10 08:38:39 字数 299 浏览 0 评论 0原文

我们能知道 swf 中什么“吃掉”最多的内存吗?怪物调试器可以吗? (我刚刚下载了它)

我的项目工作正常,但是如果我在 swf 已经启动时重新启动它(cmd+enter -> swf 启动,然后 cmd+enter),这似乎给了我一个如果我在一台非常非常慢的计算机上,情况会怎样,这是“非常”慢的示例。

那么有没有可能知道我可以删除什么来节省内存?

我使用了几个 tweenlite,没有声音,并且我在开始时加载了包含非常基本内容的所有页面 (5),因此在预加载期间...

感谢您的帮助;-)

干杯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蝶…霜飞 2024-12-17 08:38:39

请说得更具体一些——“记忆”是什么意思?

我真的不是 Monster Debugger 方面的专家,但它似乎没有解决此类问题的工具(至少网站上没有参考资料,但是这个 one)

对于RAM使用情况统计,你可以使用FlashDevelop的调试器(免费),只要Flash Builder的调试器(如果你会使用它,你应该购买它,但也有长期试用版) 可用的)。

但 RAM 并不是唯一的资源。 CPU 时间也很重要(从我的角度来看,这是闪存的主要问题)。 Flash Builder 还允许您分析您的性能(分析 - 就是获取统计数据:哪些函数被最常调用,其中哪些函数执行时间最长)。您还可以添加一些代码来收集统计信息 - 这并不难 - 只需使用 getTimer() 并查看某些代码块之前和之后的差异(但您必须猜测性能问题可能出在哪里,因为它并不容易覆盖您通过手动测量进行编码)。

另一个认为应该考虑的问题是 swf 文件大小 - 这会影响在发生任何事情之前下载应用程序所需的时间(加载屏幕不计算在内)。

更新
关于removeEventListener。
在大多数情况下,您应该将每个 addEventListener 与相应的 removeEventListener 配对。通常我在 ADDED_TO_STAGE 上添加侦听器,并在 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 );
}

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 );
}
清醇 2024-12-17 08:38:39

通常分析性能的工具称为“分析器”。 “调试器”通常是指在执行代码时用来查找代码错误的程序。

Flash 播放器(调试器版本)具有用于分析的 API。这些 API 有几个前端,其中一个,正如 Ilya 提到的,在 FlashDevelop 中,还有另一个:http://code.google.com/p/flashpreloadprofiler/。而且,如果您确实愿意,您可以编写自己的应用程序之一/检查应用程序的特定部分,就像使用以下函数编写代码一样: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/sampler/package-detail.html

从您描述的编译 SWF 的方式来看,您似乎正在使用 Flash CS# 来执行此操作。 Flash CS# 有自己的调试器(但没有分析器)。因此,如果您需要调试器,也值得检查程序附带的调试器。 IIRC 是 Ctrl+Shift+Enter。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文