安卓:创建对象的曲目编号 [英] Android: Track number of objects created

查看:131
本文介绍了安卓:创建对象的曲目编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我移植游戏到Android(有很多的code和只有很少的一部分是我的),以及DalvikVM告诉我(通过LogCat中)所有关于垃圾回收。在在code某些时候,我得到的GC释放x对象/ X毫秒的消息,基本上通知我〜150000对象刚刚被删除,它采取一整秒。流

I'm porting a game to Android (there's a lot of code and very little of it is mine), and DalvikVM is telling me (through LogCat) all about the garbage collection. At some point in the code, I get a stream of "GC freed x objects / x ms" messages, basically informing me that ~150,000 objects have just been deleted and it's taking a full second.

我想知道这些来自!我是pretty的肯定我没有创造很多对象故意。

I want to know where these came from! I am pretty sure I'm not creating that many objects intentionally.

那么,有没有办法让...该消息基本上是相反的?东西打印日志消息时,任何对象的的?

So, is there a way to get... basically the opposite of that message? Something that prints a log message when any object is created?

这样,我能跨过的code,检查是如何生成的许多消息,并看到其中code部分产生的对象。我怀疑某种形式的对象创建的循环的一部分,但如果可能的话,这将是一个简单的方法来判断是肯定的。

That way I could step over the code, checking how many messages are generated, and seeing which parts of code are generating the objects. I suspect some form of object creation in part of a loop, but if possible this would be an easy way to tell for sure.

我用的Eclipse 3.4.2 ,如果是相关的。

任何想法?

推荐答案

这是可以使用DDMS工具自带的安卓(而不是Eclipse版本)。利用这一点,来看看配置跟踪选项卡。你可以开始的所有对象的跟踪分配以及在那里他们被分配的堆栈跟踪。但是,这个工具可以产生信息的-lot-和您需要的信息并不总是容易解析或查找。如果你有一个版本的Sun JVM的,我会建议使用凯提到的工具,他们有更多的发展。如果你必须这样做在Android中,使用分配的跟踪器会给你一个开始。

This is possible using the ddms tool that comes with Android (not the Eclipse version). Using that, look at the allocation tracker tab. You can start tracking allocations of all objects along with stack traces of where they were allocated. However, this tool can produce a -lot- of information and the particular information you want is not always easy to parse or find. If you have a version for the Sun JVM, I would recommend using the tools Kai mentioned, they are a lot more developed. If you have to do it in Android, using the allocation tracker will give you a start.

这篇关于安卓:创建对象的曲目编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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