是否有可能跟踪Flash中对象之间的引用,以同样的方式作为在Flash Builder探查? [英] Is it possible to trace references between objects in Flash, in the same way as the Flash Builder profiler?

查看:118
本文介绍了是否有可能跟踪Flash中对象之间的引用,以同样的方式作为在Flash Builder探查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一个相当大的Flex应用程序的内存泄漏,我已经厌倦了用微不足道的工具,Flash Builder会使得可用的。

I'm trying to find memory leaks in a fairly large Flex application and I'm tired of using the paltry tools Flash Builder makes available.

具体地讲,我要分析的对象的关系,存储器,使用相同的信息Flash Builder的工具出现有机会获得。即哪些对象在内存中,哪些对象,他们要引用,并引用他们。给定该信息,我想构造有向图的节点是活动对象,其边缘是从一个对象到另一参考。从那里,我想搜索统治者,这应该是其中一个很好的迹象对象被泄漏。

Specifically, I want to analyse the relationships of objects in memory, using the same information Flash Builder's tools appear to have access to. I.e. which objects are in memory, and which objects they have references to, and have references to them. Given that information, I want to construct a directed graph whose nodes are live objects and whose edges are references from one object to another. From there I want to search for dominators, which should be a good indication of which objects are leaking.

我相信Eclipse一样,类似的Java的东西。

I believe Eclipse does something similar for Java.

不幸的是,Flash Builder将只允许其捕获分析数据的二进制形式,这只是可解析由Flash Builder中的出口。而不是试图扭转工程师的输出,我决定尝试捕捉数据自己,因为他们使他们的分析API提供的的 flash.sampler。* 的包。

Unfortunately, Flash Builder only allows the export of its captured profiling data in a binary form that's only parsable by Flash Builder. Rather than try to reverse engineer their output I decided to try to capture the data myself, since they make their profiling API available in the flash.sampler.* package.

到目前为止,我设法收集那些目前居住在内存中,得到他们的分配跟踪的对象,并引用我可以检查的对象,这是大多数我所需要的。但我无法弄清楚如何在FB探查回溯引用到GC根。我可以看到这样做的唯一方法是检查每一个对象在内存中,并为每个对象检查它的各个属性,依此类推,直到我找到一个链归类为根级的对象。但是,因为我只能遵循公开的属性引用,这是完全有可能我会想念大量引用了prevent垃圾收集的。

So far I've managed to collect the objects that are currently live in memory, get their allocation traces, and references to the objects that I can inspect, which is most of what I need. But I can't figure out how the FB profiler traces back-references to the GC root. The only way I can see to do it is to inspect every object in memory, and for each object inspect each of its properties, and so on, until I find a chain to an object classified as "root" level. But since I can only follow references on publicly visible properties, it's entirely possible I'll miss lots of references that prevent garbage collection.

如何在Flash Builder探查办呢?

How does the Flash Builder profiler do it?

我怀疑的是,它不只是用取样器。* API来获取信息,但补充,通过调试器连接,这可能是超出范围对我的工作进行查询。但在没有任何方法来验证,我希望有可能只用取样器的API。

My suspicion is that it doesn't just use the sampler.* API to capture information, but supplements that with queries performed through a debugger connection, which is probably out of scope for my work. But in the absence of any way to verify that, I'm hoping it's possible using only the sampler API.

推荐答案

其实在恕我直言,如果Flash(Flex的)生成器的内存/性能工装的微不足道的,那么你不使用它的权利。关键要了解你的工具可用 - 自4.0 SDK,并已经可以和我一直在使用它,我被分配到作为运行时分析-家伙每一个项目

Actually in IMHO if Flash (Flex) Builder's memory / performance tooling is paltry then you aren't using it right. The key to understanding the tooling you have available - has been available since the 4.0 SDK and and I've been using it for every project I've been assigned to as the 'runtime-analysis-guy'.

实时查看:
我们都知道这一次,它给你一个活的看法什么是当前可用。虽然当前实例计数是有用的,什么是更有益的是累积的。这有助于追查其创建的的错误的方法太多的的对象。

Live View:
We all know about this one, it gives you a "live" view of what's currently available. While the current instance count is useful, what's even more useful is the cumulative. This helps track down the errant methods which create way too many objects.

游荡对象视图:
你可能没有使用这一个,但相信我,一旦你做,你不回去了。有了这个它有助于清楚地定义了小屏幕/应用程序状态(如:1.起点,2.创建一个对话框3.收盘点位是相同的状态1的能力)。在您的应用程序,让你要测试的地方。然后点击内存快照功能 - 在彩色线条图标。现在,在您的应用程序,通过步骤2执行和3返回到分析器,然后再次单击此。在这里,您现在可以终止或暂停您的应用程序。选择两个内存配置文件,然​​后单击游荡对象功能 - 绿色的图标。在理论上,这将是空的,但它不会。这表明你是什么对象都被标记为[扫描]而非[收获]主编。

Loitering Object View:
You probably aren't using this one, but trust me once you do, you won't go back. With this it helps to have clearly defined small screen / application states (eg. 1. A starting point, 2. The ability to create a dialog 3. A closing point which is the same state as 1). In your application, get to the place you want to test. Then click the memory snapshot function - the "colored lines icon." Now in your application, run through steps 2 and 3. Go back to the profiler, and click this again. Here you can now either terminate or pause your application. Select both memory profiles and click the loitering object function - "the green icon." In theory this list will be empty, but it won't. This shows you what objects have been marked for [sweep] but not [reap]'ed.

D-点击任何对象,这使你每引用仍持有到该对象的列表的详细信息视图。我会给你一个提示,现在,如果你还没有在你的应用程序中创建一个解构的过程(如IDestroyable接口),就此打住吧,回去和做到这一点。 您必须将空的每一个对象,它是不是一个复杂的灵长类动物。这意味着每一个类,每一个阵,向量,事件监听等。

D-Click any object and this gives you a detail view with a list of every reference that still holds onto this object. I'll give you a hint right now, if you haven't created a deconstruction process in your application (eg IDestroyable interface), stop right now and go back and do this. You must assign null to every object that is not a complex primative. This means every class, every array, vector, eventlistener and so on.

采样包是工具使用,据我所知的唯一的事情 - 毕竟该工具不注入任何code到应用程序在调用的时候。它与NewObjectSample和将deletedObjectSample所有对象的比较,并在getSavedThis看()回到了原型链(这应该返回一个对象,你可以调用getSavedThis()就可以了等等)。

The sampler package is the only thing the tool uses as far as I'm aware - after all the tool doesn't inject any code into your application at the time of invocation. It's a comparison of all objects with the NewObjectSample and the DeletedObjectSample, and looking at the getSavedThis() going back up the prototype chain (this should return an object where you can call the getSavedThis() on it and so on).

http://help.adobe.com/en_US/flashbuilder/using/WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7edf.html

希望这有助于。

这篇关于是否有可能跟踪Flash中对象之间的引用,以同样的方式作为在Flash Builder探查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆