Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 2:09 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Byte array optimizatoin
PostPosted: Mon Mar 19, 2012 7:54 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
I have a game that is running into memory problems (it's running on android). After profiling, I found that around 50% of the memory is in byte[] objects, so of course, I want to optimize whatever is creating byte arrays. Does slick use byte[] object often? If so, where?

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Mon Mar 19, 2012 8:28 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1469
Most of it is probably from textures and sounds.

  • Use the new InternalTextureLoader.getTextureCount() method to determine how many textures you have. If this is greater than what you're expecting (based on how many you are loading), then you have a lot of room for optimization.
  • Ensure all of your images are power-of-two size to begin with
  • Be sure to release images/sounds that are no longer used
  • Stream music/sounds instead of loading them into memory, unless you need low latency
  • Don't use ImageBuffer, Image.getGraphics, or Image.getColor -- these are expensive for Android purposes and require a lot of extra memory
  • Some of the problem might lie in Slick's current manner of caching and holding texture data (for reloading on context switches, for example). In many cases you may have images that you don't need to be held/reloaded, but there is no easy way (that I can see).
  • Change slick source and expose the buffer size in Slick-AE's GDXRenderer -- by default it allocates 50,000 floats (200,000 bytes) which might be more than you need for your game's rendering


Top
 Profile  
 
PostPosted: Wed Mar 21, 2012 8:49 pm 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
imho cache all your stuff when preloading your game
a good performance test is to do a dump on your resourceloader, after pre-loading it shouln't load anything anymore on runtime
the rest should be streamed, also tweak the particle emmitter system if you run on slick


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group