views:

18

answers:

1

OK, I'm working on a project right now and I need to create a graphic library.

The game I'm experimenting with is an RPG; this project is expected to contain many big graphic files to use and I would prefer not to load everything into memory at once, like I've done before with other smaller projects.

So, does anyone have experience with libraries such as this one? Here's what I've came up with:

  • Have graphic library files and paths in an XML file
  • Each entry in the XML file would be designated "PERMANENT" or "TEMPORARY", with perm. being that once loaded it stays in memory and won't be cleared (like menu-graphics)
  • The library that the XML file loads into would have a CLEAR command, that clears out all non-PERMANENT graphics

I have experience throwing everything into memory at startup, and with running the program running with the assumption that all necessary graphics are currently in memory. Are there any other considerations I might need to think about?

A: 

Ideally everything would be temporary and you would have a sensible evict function that chooses the right objects to victimize (based on access patterns) when your program decides it needs more memory.

There'll be some minimum amount of RAM your game needs to run, otherwise stuff will be constantly swapping, but this approach does mean you're not dumping objects marked TEMPORARY that you will just need to reload next frame because you happen to be using it currently.

John Shedletsky