DDMS的Andr​​oid和分配跟踪 - 确定是什么原因造成的GC触发以及为什么 [英] Android DDMS and allocation tracking - Identifying what is causing the GC to trigger and why

查看:162
本文介绍了DDMS的Andr​​oid和分配跟踪 - 确定是什么原因造成的GC触发以及为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好。

我一直在为Android小的基于OpenGL的应用程序,在循环正常60帧,并做各种奇妙。

I have been making a small openGL based app for android that loops at the normal 60 fps and does various wondrous things.

我一直珍藏在我的帧速率的眼睛,试图优化在可能的情况,因为我去一起。我最近注意到,虽然我的程序正在运行有时会出现轻微的停顿。我立刻怀疑这可能是垃圾收集器运行,并在寻找LogCat中有少数嫌犯GC的周围出现抄底时代的FPS。

I have been keeping an eye on my frame rate and trying to optimise where possible as I am going along. I recently noticed that whilst my program is running sometimes there will be a slight pause. I immediatly suspected that it might be the Garbage Collector running and looking in LogCat there were a few suspect GC's appearing around the times of the dips in fps.

但我不能确定它是否是我的应用程序,导致了收集。

However I am unsure if it is my app that is causing the collects.

因此​​,这些都是我对GC的问题:

So these are my questions about the GC:

1),当我从LogCat中记录它包含了一个PID(进程ID),这里是我收到一个典型的GC的例子:

1) When I get logging from LogCat it contains a PID (process id?) and here is an example of a typical GC i receive:

12-14 14:52:40.647: DEBUG/dalvikvm(492): GC_EXPLICIT freed 3831 objects / 203576 bytes in 32ms

492是PID。是该PID将是它执行的GC方法的?抑或是还需要一个GC在手机上运行的进程?

The 492 is the PID. Is this PID going to be of the process that performs the GC? Or is it a process running on the phone that is also needing a GC?

例如从这里同一会话使用Log.debug从我的应用程序日志:

For example from the same session here is a log from my app using Log.debug:

12-14 13:50:42.717: DEBUG/Curve(2298): LIFECYCLE - OnStart

将PID为我的应用程序是不是492,是2298.这是否意味着GC是不是因为我的应用程序?

The PID for my app is not 492, it is 2298. Does this mean the GC was not due to my app?

使用分配跟踪我已经很少分配存在的。要生成日志引起一些字符串了几行,在用户preSS生成偶尔矩形(我已经解决了这个问题,因此只会被现在分配一次......)所以我看不出我的应用程序本身会可生成GC的需求。

Using the allocation tracker I have very few allocations occuring. A few lines of logging causing some strings to be generated and the occasional Rect being generated on a user press (I have fixed this so it will only be allocated once now...) So I cannot see how my app itself will be generating the need for GC's.

2)如果不是我的应用程序分配路程,很简单,就是吃入内存高兴地应影响我的应用程序在所有其他进程?

2) If it is not my app allocating away and is simply some other process that is eating into memory happily should it affect my app at all?

3)能张女士我使用DDMS会导致GC的?

3) Could the very fact I am using the ddms be causing GC's?

4)当我看向分配跟踪有不来自于我运行/通过自己去任何code某些条目。其中之一是线程统计,会是这样的DDMS有关?

4) When I look in to the allocation tracker there are some entries which do not come from any code that I am running / going through myself. One of which was related to thread stats, could this be the ddms?

很抱歉,如果这真的是几个问题,但它是所有涉及到真的GC日志我在LogCat中看到是否实际上是从我的应用程序或没有。

Sorry if this is really several questions but it is all related to really whether the GC logs I see in my Logcat are actually from my application or not.

轴承在此刻我的手机没有坐在我的运行应用程序,我仍然得到小GC的5记 - 15秒。这些正常运行为33ms,似乎相当少量的内存。所以我想这意味着他们是不是因为我。 - 基本上再次对PID什么,显示

Bearing in mind that at the moment my phone is sat not running my app and I am still getting small GC's 5 - 15 seconds. These normally run for 33ms and seems quite small amounts of memory. So I guess this means they are not due to me. - Again basically about the PID and what that shows.

推荐答案

您是正确的:1)。只有GC日志ING LogCat中的一个子集属于您的应用程序,而那些有你的应用程序的PID。

You are correct on 1). Only a subset of the GC logs ing Logcat belong to your app, and those have your app's pid.

最有可能的打嗝是由于后台服务请求的小分配。我建议你​​在游戏中应用低通滤波器,该增量时间帧之间或加盖的最高FPS的整体流畅的体验。即使在iOS上它extremelly很难有在60FPS你的游戏运行没有最终打嗝。

Most likely the hiccups are due to background services requesting small allocations. I'd suggest you apply a low-pass filter to the delta time between frames in your game or cap the maximum FPS for an overall smoother experience. Even on iOS it's extremelly difficult to have your game running at 60FPS without eventual hiccups.

这篇关于DDMS的Andr​​oid和分配跟踪 - 确定是什么原因造成的GC触发以及为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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