Memory management in multiplayer game

Forum for discussion about developing multiplayer games for mobile platform including Httpconnection and bluetooth connections.

Memory management in multiplayer game

Postby jestan » Wed Nov 28, 2007 6:40 am

Hi,
I am trying to implement a multiplayer game over bluetooth (It is an arcade game). Server runs on PC and clients run on Mobiles. I would like to ask a question about memory management in Mobile. In client side, i am using two threads to receive and send game updates to server. My GameCanvas has two vectors to add local game update and remove incoming update. Two threads uses the above vectors as a buffer. My doubt is , at run time what will be the memory usage of those vectors :?: Will the game have the ability to run on real mobile devices.
Thanks.
Jestan
jestan
 
Posts: 22
Joined: Thu Jun 14, 2007 11:26 am

Re: Memory management in multiplayer game

Postby DevelopmentTeam » Wed Nov 28, 2007 7:29 am

Dont use 2 threads when using a hardware based API... We usaully get error in some devices. Use a single thread unless you really require it. And using vector is another fatal issue that may shoot out if you are not managing properly so better avoid using vector.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Memory management in multiplayer game

Postby jestan » Wed Dec 05, 2007 6:17 am

Thanks for the reply. :D

The game is working fine in WTK emulator.The threads did not use the bluetooth API directly, they use Streams who came from
StreamConnection object. I coud not understand the phrase "using vector is another fatal issue". Could you give some examples about the alternative data structure? Memory monitor tool shows that lot of char[], String, int[] objects created at runtime. Can
i decided to use a thread for garbage collection for every 2 min in Client side. By doing this can i improve memory usage. Please give some hints.

Thanks
Jestan.
jestan
 
Posts: 22
Joined: Thu Jun 14, 2007 11:26 am

Re: Memory management in multiplayer game

Postby DevelopmentTeam » Wed Dec 05, 2007 6:38 am

Garbage collection request in J2ME cannot be trusted in most of the JVMs. As they are only a request call. Usually when you call GC it doesnt only when the CPU is free and not so often. So you will have to resuse declared objects again and again as much as you can. You should not declare any new object during runtime of the game. You should do all stuff during the game loading.

Vector is not a good option in most of the cases. As it is the easiest way you can choose to waste memory. If a vector is often manipulated with delete, add commands you will soon get the out of memory exception. So I better suggest not using it.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Memory management in multiplayer game

Postby jestan » Thu Dec 06, 2007 6:28 am

Thanks for the reply :)
I have decided to deploy my jar in Sony Ericsson K550 and Heap size: 1.5-3MB .In emulator i saw that, my Midlet consumes 100KB while launching the game. After that there is no spikes in memory graph, but goes slightly upwards when i press fire button or arrow keys. Can i expect, my app won't face memory at least for few mins :)
Thanks

Jestan.
jestan
 
Posts: 22
Joined: Thu Jun 14, 2007 11:26 am

Re: Memory management in multiplayer game

Postby DevelopmentTeam » Thu Dec 06, 2007 8:53 am

It is suppose to work fine as per what you said. But it still depends on the code untill you really test it on the target device.

Mobile Games need 99% testing on the real device otherwise you need very good experience with your prior games tested on the devices, otherwise you cannot expect 100% assurance.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Memory management in multiplayer game

Postby jestan » Sat Dec 15, 2007 6:15 am

Hi,
I have tested my multiplayer game in Sony Ericsson W810i,Sony Ericsson k55i. The game worked fine. I used many vectors for handling bullets,for message sending receiving . Performance was more than WTK emulator. I coudn't feel the network delay even.

Jestan.
jestan
 
Posts: 22
Joined: Thu Jun 14, 2007 11:26 am

Re: Memory management in multiplayer game

Postby DevelopmentTeam » Sat Dec 15, 2007 6:36 am

What kind of game is it? Are you trying a realtime multiplayer game?
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Memory management in multiplayer game

Postby jestan » Sat Dec 15, 2007 11:10 am

It is a 2D arcade realtime multiplayer game( It is not isometric) with bluetooth game server in PC. Two phones can get connected with the server for a game session. In the game, players provided with a battle tank and they can ,explore the map in four directions,shoot other player( All are in realtime).Now i am planing to extend the number of players.

Jestan
jestan
 
Posts: 22
Joined: Thu Jun 14, 2007 11:26 am

Re: Memory management in multiplayer game

Postby DevelopmentTeam » Sat Dec 15, 2007 11:52 am

wow, thats nice to hear. I thought it was GPRS multiplayer. Thats why I doubted if it could run that fast. :)

Congratulations.
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to Multiplayer Mobile Games

Who is online

Users browsing this forum: No registered users and 1 guest