[rabbitmq-discuss] Java Client + Android
therevoltingx at gmail.com
Tue Jun 15 09:57:07 BST 2010
Well, the only method that the Android docs provide is to call
System.gc() which make the JVM schedule a GC run.
This wouldn't help in the inner loop, but it's what I do right after I
connect and setup the queues.
I'm not sure how I can influence the GC in a stock android device beyond that.
>From googling on how to influence the GC in java, some people give
some tips such as setting the objects to null, and some other java
trickery that I'll have to try.
However, from the android google blog, it seems the dalvik (which
android uses) JVM doesn't support such optimizations:
Also, the JIT is coming to Android soon, I'm not entirely familiar
with how it works, but I'll keep looking. I'm not sure if this will
work on the older devices though.
Other than that, I haven't tried any other compiler trickery, mainly
because this is my first app using java.
Again, any java related hints would be appreciated.
On Tue, Jun 15, 2010 at 12:31 AM, John Apps <johndapps at gmail.com> wrote:
> This is probably way off the mark, and something you have sure to have
> tried: changing the GC parameters? Or is this not possible on the Android? I
> assume this is Java 6?
> How is Java started on Android or, perhaps better question, can you
> influence the GC parameters?
> On Tue, Jun 15, 2010 at 02:36, Miguel Morales <therevoltingx at gmail.com>
>> 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
>> 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:
>> 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
>> You can see the C/JNI version here:
>> Any help in this would be appreciated!
>> http://diastrofunk.com, http://developingthedream.blogspot.com/,
>> http://www.youtube.com/user/revoltingx, ~Isaiah 55:8-9
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
> John Apps
> (49) 171 869 1813
http://www.youtube.com/user/revoltingx, ~Isaiah 55:8-9
More information about the rabbitmq-discuss