Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Logcat profilier and performance hiccups

Discussion in 'Android' started by beezir, Sep 28, 2010.

  1. beezir

    beezir

    Joined:
    Apr 3, 2009
    Posts:
    133
    My current work in progress occasionally (and unpredictably) has short pauses of up to a second or two which I assume are the GC - correct me if this is a poor assumption. The actual memory usage and drawcalls are pretty low so I used logcat to profile the game... however, I don't really know what I should be looking for in the resulting log file. What are some warning signs that I should keep an eye out for, and is there any easy way to narrow down where in the log my sudden pauses are?

    Additionally, the pauses only seem to occur on the first playthrough, second time or more (even completely exiting and reloading the app) and everything is smooth. If I delete the app and reupload it, the first run has these odd performance issues again. Any ideas why?
     
    Last edited: Sep 29, 2010
  2. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    The only thing I can think of is excessive use of PlayerPrefs as those are cleared when you uninstall the app completely. PlayerPrefs are backed by a Java object (which in turn is backed by an SQL database iirc); accessing it (especially writing/reading interleaved) is quite expensive operation and should not be done on a per-frame basis. If you see anything like
    Code (csharp):
    1. D/dalvikvm( 6554): GC freed 5071 objects / 326664 bytes in 49ms
    in the logcat that means the Java GC is kicking in.

    What device are you running on?
     
  3. beezir

    beezir

    Joined:
    Apr 3, 2009
    Posts:
    133
    Hmm, so far I haven't been using PlayerPrefs (or any form of persistence) whatsoever. I'm testing on a Droid 2 at the moment.

    I'll comb through and start looking for any excessive GC calls and make sure there aren't any C# classes being instantiated excessively (per-frame or whatever). Still curious that the 2nd+ runthrough removes the problem entirely.