Lots have been said here and I just want to say that as a fellow real
time game developer I have the exact same problem.  I will even go as
far as to tell you the name of an app that this happens in, my most
popular game "BreakTheBlocks Lite", which hit a million downloads last
month :), has this problem.
The majority of the bad feedback that I receive on this game, besides
the usual highly intellectual 1 star comments of "this sucks" and
"borrrriiiinnnnngggg!!!!", are related to how bad the lag is.

When I initially made the game lag was horrible, and looking at logcat
output in eclipse it seemed to be happening whenever garbage
collection occurs.  After a question on this group a year or so ago I
found out about the allocation tracker in the standalone DDMS tool and
was able to get rid of the majority of my allocations.  My code still
creates some objects, but that is all part of string generation and I
haven't put in the time to see if there is a decent way of generating
a basic string using some numbers without causing allocations.

I have 3 android devices, ADP1(1.5-HVGA), Tattoo(1.6-QVGA), and Nexus
1(2.1-WVGA) and they all have the same behavior in regards to the
"lag" I see in this game.  Basically playing the game after killing
all tasks with Taskiller or Advanced Task Manager I can play the game
with relatively little lag, once every minute or 2.  However if I open
my twitter client, facebook, browse the web for a few minutes, and
then try to play this game I get lag at least every 20 seconds or so
and every time I see this lag I see that garbage collection is
happening in the log.

I gave up on trying to solve this problem many months ago.  The best I
could ever do was call System.gc(); whenever there was a break in real
time action, and cut down on allocations as much as possible.  If I
recall there is not much that you can do about other processes garbage
collection, when the garbage collector starts up there is nothing that
your app can do, so in a real time game that means the game loop gets
put on hold, and by the time the game loop runs you have already
missed a fraction of a second which means during that fraction of a
second you cannot update the screen or calculate  any of the game
logic/physics and when the scree finally does get updated the user
just sees "lag".

If anyone has any suggestions on how to suppress the garbage
collection done by other processes or how to write an app that can
continue it's game loop / screen updating during the garbage
collection I am all ears.

---snctln
www.snctln.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to