valzkat1 / andors-trail

Automatically exported from code.google.com/p/andors-trail
0 stars 0 forks source link

OutOfMemoryError when running ResourceLoader #171

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
We have a lot of new maps (>70) being made, that we should include in the next 
release.

However, when including all of them in the game currently, the resourceloader 
cannot complete its work because it gets an OutOfMemoryError when trying to 
load the tile images after having loaded all maps.

This is a sign that we are caching too much information. Currently, everything 
is loaded when the game starts, so that it is readily accessible from 
everywhere. This includes all 3 layers of all maps, the walkability matrices of 
all maps, and all used tiles for all maps and all monsters. Apparently, this is 
too much to contain in the limited heap space that we have.

We should aim at using only 10MB heap memory. 

A rudimentary memory profiling of the problem shows that we are using about 2MB 
only for the map layer information. This is by far too much, since we don't 
have any need for using all of that data at the same time. Instead, we should 
implement a dynamic map loader that loads the map layer information only when 
the player visits the map, instead of always loading all of it for all maps.

Actually, only the current maps needs to have its map layers loaded. Other maps 
could be GC:ed.

Original issue reported on code.google.com by oskar.wi...@gmail.com on 22 Mar 2011 at 9:53

GoogleCodeExporter commented 8 years ago
This should now be resolved by r61 .
Maps are now loaded in two stages:
1) When the game starts, all maps are loaded to determine which tile images are 
used, so the images can be cached. Map layers (ground, objects, above) are not 
cached.
2) The map layers (ground, objects, above) are loaded when the player enters a 
new map. Only the layers for the current map is loaded into memory.

The operation (2) is very fast, sub-second performance. This makes the gameplay 
identical to before, but just with better memory management.

Marking this issue ready for v0.6.9 .

Original comment by oskar.wi...@gmail.com on 23 Mar 2011 at 7:10

GoogleCodeExporter commented 8 years ago
Released in v0.6.9 . Closing.

Original comment by oskar.wi...@gmail.com on 29 Jun 2011 at 7:51