Archived

This topic is now archived and is closed to further replies.

[java] memory usage

This topic is 5747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hmm.. If I make a game which at first loads lots of tiles in the init() code and then only paint them as they appear on the screen, will tiles that has been painted, but isnt in the viewing area for the moment, take up as much memory as the ones onscreen? How many different tiles do you belive is appropiate for a game to load per level, if size=32*32? Im doing an RPG and would like to load lots of tiles into a really big map.. Maybe about a hundred.. Would this work with speed?

Share this post


Link to post
Share on other sites
If you load all of the tiles in the init() code, that means all those tiles will no matter what be taking up memory. If they are currently visible on the screen, the tiles themselves take up the same amount of memory, though there will be overhead associated with the painting itself (since the number of tiles on the screen at once is probably semi-constant, this overhead will probably also not change much..).

As for the question of how many tiles are appropriate to load per level, if you have a level size of 32x32, you will have 1024 tiles. Of course not all of these will be the same, but it''s hard for me to give you a number and say that you should stay below it. By your method of loading tiles, you will probably have to experiment to see how bad loading times are, and if memory usage is too bad.

Would this work with speed? I really can''t tell you. Try it first, and optimize later if you find that it''s a bottleneck. To make a wild stab I would think that this will work just fine.

-pirate_dau

Share this post


Link to post
Share on other sites
Im sorry but i belive I explained a bit wrong.. What i meant was that my tiles are 32*32 big and the screen is 320*256. The map would be about 200*200 tiles big..

But anyway, how many loaded tiles do you belive the memory of a not so speedy computer could hold at once? Is it something like 40 or more like 1000?

Share this post


Link to post
Share on other sites
Ideally, your engine would have about 8 bytes (or less) of info for each tile. (Info such as which image it uses in a tileset, it''s height / other properties).

With a 200*200 grid on your map, that''s 40000 tiles, or at least 320000 bytes of info. That''s not anything to worry about. Just try to keep the amount of info you need in each tile to a minimum. You probably need an integer indexing into the different tiles in a tileset, maybe the height of the tile (if you use that), and another byte for other properties.

Share this post


Link to post
Share on other sites