Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to know if anyone has recommendations or experience with using an in memory data store for a real time, non-networked game. This is not necessarily for loading levels or saving data, but to be accessed within the game loop as the game is running. Pretty much everything I look at w.r.t. data stores in games refers to networked games like MMOs.

As I am working on my game I find myself building a lot of ad hoc structures to hold various bits of game data and I was thinking it would make more sense to leverage work in this area that would provide a more consistent (and hopefully efficient) retrieval/storage method.

Does anyone have any experience or recommendations on in memory databases or key value stores or document stores that would be reasonable?

For my own purposes, my game is being written in Scala but the answers don't need to be Scala/Java specific.


To be more specific I am primarily talking about entity data and lists of entities not necessarily things like 3D meshes.


4 Answers 4

I see two things that need to answered here:

First of all, the simple data structures that you build through normal code are way more efficient than any kind of database, you should as far as possible store your data using those.

If you have a real need to reference data by a string name you should use a search tree, I'm sure you can find a library that implements one.

I want to be able to do things like "Get all of the ogres in the forest without a weapon" and some place else "Get all buildings that haven't been damaged". I feel like there is a more consistent way to do this. I don't want to necessarily say a SQL interface but some more consistent means of querying game data that is at least reasonably performant. –  Michael Jan 5 '12 at 22:26
For that sort of stuff you keep lists, simple linked lists may be what you are looking for. So you could keep lists of all those ogres and if one of them gains a weapon remove it from the list, if an unarmed ogre enters the area add it to the list. But most of the time you probably don't want to keep too many lists, making a list for each type of entity for each area will probably be sufficient. If there is less than a thousand enemies in an area it is no big deal to go through the lot and find all unarmed ogres whenever you so desire. –  aaaaaaaaaaaa Jan 5 '12 at 23:02
@Michael those things you want to do sound exactly like the LINQ where clause. You can do similar things with lambda expressions inside of find statements in C++. You don't need a "data store" to do those kinds of queries on your data in an easy way, as long as you're using a relatively modern language. –  Tetrad Jan 5 '12 at 23:03

If you want what is essentially a database, then you might be best off using one. For example http://www.sqlite.org/ can be compiled in with your code, and can store it's data in RAM if you want.


The purpose of anything that you would actually call a "database" is primarily to make searching and finding specific information easy and fast. Unless you have some need to find entities via specialized queries based on many of their properties, you don't need a database. You just need a simple array or map or whatever.

A simple thing like "find entity by name" is something that your programming language's standard library can cover. In C++, the first go-to type for this would be std::map.


RDM Embedded has a free evaluation download and the database has pure and hybrid in-memory capabilites. http://raima.com/products/rdme/

Hello, for an answer that links to a product to not be considered spam we require that you disclose your involvement with the company/product. Also, could you please provide more information to indicate how this solves or is related to the Original Poster's problem. –  Noctrine Feb 2 '12 at 21:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.