ActionScript 3的探查和放大器;内存分析工具放大器、内存、工具、ActionScript

2023-09-08 11:13:10 作者:荒住着两个诚

我使用的Adobe Flash CS 4,想知道是否有可用的任何事件探查器或内存分析工具? (动作3)。我知道有可用的工具用于Flex的,但是否有对Flash CS 4呢?谢谢你。

I'm using Adobe Flash CS 4 and would like to know are there any profiler or memory analysis tools available for it ? (actionscript 3). I know there are available tools for Flex, but are there for Flash CS 4 instead? Thanks.

推荐答案

我敢肯定有一个程序在那里,仍然在寻找自己,但我的发现这对一个论坛:

I'm sure there is a program out there, still looking myself, but I found this on a forum:

大多数AS3初学者有编程的东西,然后听说了内存泄漏。所以首先我要说的是,如何检测和修复preexisting code泄漏,然后再谈preventative措施开始程序时服用。

Most AS3 beginners have programmed something and then heard about memory leaks. So first I'm going to cover ways to detect and fix leaks in preexisting code, and then talk about preventative measures to take when starting to program.

所以,你怎么知道你的程序有问题?告诉最明显的方法是,如果它崩溃了,但是这是非常不切实际的。幸运的是,在AS3中有一个名为系统,其性能给我们介绍一下下的Flash运行条件的对象。 System.totalMemory,例如,是计算机内存中正在使用的是正在运行程序中的Flash Player实例的数量。不同的平台确定System.totalMemory方式不同的价值,所以我建议你只在一个时间衡量其价值,当运行一个Flash播放器的实例。

So how do you know if your program has an issue? The clearest way to tell is if it crashes, but that's very impractical. Fortunately, in AS3 we have an object called System whose properties tell us about the conditions under which Flash is running. System.totalMemory, for instance, is the amount of computer memory being used by the Flash Player instance that's running your program. Different platforms determine the value of System.totalMemory in different ways, so I suggest you only run one Flash player instance at a time when measuring its value.

package {

    import flash.utils.Timer;
    import flash.system.System;

    public class SpitMem {
        var t:Timer = new Timer(0);
        var n:int, lastN:int;

        public function SpitMem():void {
            t.addEventListener("timer", spit2, false, 0, true);
        }

        private function spit1():void {
            trace(System.totalMemory);
        }

        private function spit2():void {
            n = System.totalMemory;
            if (n != lastN)
                trace(n);
            lastN = n;
        }
    }
}

如果您创建上面的SpitMem类的实例,并运行code,你可以看到在输出窗口程序的内存使用量的波动。这是很多的信息,但是,在这种格式是不能给你的你的程序是如何使用其内存的清晰画面。

If you create an instance of the SpitMem class above and run your code, you can observe the fluctuations in your program's memory usage in the Output window. This is a lot of information, though, and in this format it cannot give you a clear picture of how your program is using its memory.

(注意上面的差异spit1()和spit2()之间。spit2()将不会输出System.totalMemory,如果它没有改变。以后我会告诉逻辑何其相似可以将我们的数据转换成更多的东西有用的。)

(Notice the difference above between spit1() and spit2(). spit2() won't output the System.totalMemory if it hasn't changed. Later I'll show how similar logic can turn our data into something more useful.)

如果你让你的数据图中为preadsheet程序,你会发现,它似乎总是在增加。这并不意味着你有内存泄漏。 Flash的内置内存管理使某些类型的数据,坐下来,直到有一个合适的时间,以摆脱它。这就是所谓的垃圾收集,而对于大多数Flash项目,它会导致你的记忆积累,再浸下去。这就是所谓的锯齿曲线图,这是完全正常的。

If you make a graph of your data in a spreadsheet program, you'll notice that it always seems to be increasing. That doesn't mean that you have a memory leak. Flash's built-in memory management allows certain types of data to sit around until there is an appropriate time to get rid of it. This is called garbage collection, and for most Flash projects, it will cause your memory to accumulate and then dip down. This is called a sawtooth graph, and it's completely normal.