[rabbitmq-discuss] Java Client + Android

Miguel Morales therevoltingx at gmail.com
Tue Jun 15 01:36:59 BST 2010


Hi all,

For the past few months I've been developing a game using Android and
the rabbitmq java client with fair results.
Setting it up was fairly painless, however, I've run into one issue
that's making one of the key parts of my game suffer.
In Android, every time the garbage collector runs, the CPU is busy for
a few milliseconds, ~200ms.
This slows the frame rate and causes the game to stutter for a bit.

The problem is in consuming messages, I have a thread that simply
reads from a queue as fast as it can delivers the body bytes to the
game client.
However, in the library there are a bunch of small allocations that
happen which causes the GC to run at least once every 10 seconds,
using both a consumer and a basicGet.

I've tried to look at the code and remove allocations, and have got
the GC runs down to about 1 every 40 seconds.  Still, that GC runs and
constant allocations
are hindering my ability to render some decent maps on the older
Android models (I use a G1)

I also tried briefly to get the rabbitmq-c client working, and I was
successful.
However, I hit a roadblock when trying to send the body bytes back to
the JVM using JNI.
I keep running out of memory or crashing using a jbyteArray buffer.

My C is pretty rusty so I was hoping someone had some suggestions
regarding that.
Ideally, I'd just be able to get rid of the allocations while
consuming messages, any help is appreciated!

I've created a test application for android to test out the different
consuming implementations in github:
http://github.com/therevoltingx/rabbitmq_android_test

You can see how fiddling around with the internal java client code I
was able to get rid of some allocations here (simply by caching
Basic.Get):
http://github.com/therevoltingx/rabbitmq_android_test/blob/master/src/com/diastrofunk/rabbitmqtest/JavaTests.java#L74

You can see the C/JNI version here:
http://github.com/therevoltingx/rabbitmq_android_test/blob/master/jni/ndktests.c

Any help in this would be appreciated!

Thanks,
Miguel

-- 
http://diastrofunk.com, http://developingthedream.blogspot.com/,
http://www.youtube.com/user/revoltingx, ~Isaiah 55:8-9


More information about the rabbitmq-discuss mailing list