Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old September 12th, 2011, 12:08 PM   #1 (permalink)
New Member
 
Join Date: Dec 2010
Posts: 5
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Android - Bluetooth garbage collector

Hey!

I am developing a real time game. Therefore, I also want to provide a Bluetooth multiplayer mode. Now there is my problem… When I commit the information to the other device I need to parse it. I send ~ 30 messages a second. Everything is working fine except the garbage collector. When I run the game it lags every second cause of the running garbage collector.

I have tried to send an xml and parse it by a SAX parser…. But there the GC starts…
I also tried to send my own primitive data… the result is the same… when I split the strings the GC gets started… Also when I try to convert my strings to other values (int/float …) the GC is started.

I really have no clue how to avoid this!!

It would be great if someone can give me a hint how to send and receive real time information without starting the garbage collector!!!

monnti is offline  
Reply With Quote
Sponsors
Old September 12th, 2011, 04:01 PM   #2 (permalink)
Senior Member
 
Join Date: Jul 2010
Posts: 977
 
Device(s): Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Thanks: 52
Thanked 199 Times in 144 Posts
Default

Unfortunately, there really isn't a way around this... in Java at least... Your best bet would be to use the JNI, find a C/C++ BT library and write it in native code.
jonbonazza is online now  
Reply With Quote
Old September 13th, 2011, 02:54 AM   #3 (permalink)
New Member
 
Join Date: Dec 2010
Posts: 5
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have looked inside of the AndEngine Multiplayer Extension. They use a DataOutputStream/DataInputStream. But I’m not sure if this will avoid the GC <.<

But I’m a bit confused… would they use a method that isn’t able to provide real time game preformance? O.o


@jonbonazza
Do you have a name of any good native BT library?
monnti is offline  
Reply With Quote
Old September 13th, 2011, 10:24 AM   #4 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

How large are your messages? Can you trim them down and/or can you keep to only sending when needed, and predicting movement/behavoir when waiting for a message?

If you've ever noticed this is what online games have done for years due to latency etc. When you see a character run sometime they will "rubber band" when stopping or changing direction. That's because the actual position data just caught up with the predicted position.
alostpacket is offline  
Reply With Quote
Reply

Bookmarks

Tags
android, bluetooth, garbage collector, multiplayer game


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:46 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo