Memory & Game Content
1
Memory & Game Content 1 Memory is precious Memory is precious, - - PowerPoint PPT Presentation
Memory & Game Content 1 Memory is precious Memory is precious, especially on simpler devices. Even on PCs need to be cautious, using too much memory tends to drive you off a performance cliff Memory fragmentation (or address space
1
– Even on PCs need to be cautious, using too much memory tends to drive you off a performance cliff
can be a problem for consoles as well as memory exhaustion
space to improve your game with more content
bandwidth, so it’s getting harder to fill memory with content in reasonable time
– Code
code memory
– Stack – Heap (global/shared/dynamic memory)
int g[256]; // 1 kB of code memory void some_function() { static int i[16]; // 64 bytes of code memory }
system
– Per thread – The programmer might have a say in this. For example, set during thread allocation
– Per function overhead – Local variables in function
void some_function() { int i[16]; //64 bytes on stack }
the problem.
// Dangerous linked-list deletion! void DeleteNode( Node* n ) { if ( n == NULL ) return; DeleteNode( n->mNext ); delete n; } SomeBigStruct temp[65536]; // !!??
– Allocated/freed via new/delete/malloc/free
purposes.
– E.g. world art should not take up more than 84MB. – Budgets usually determined, enforced and tweaked by senior programmers on the game team. – If so, need to overload new/delete (or malloc/free)
– Create/delete fixed-size objects, up to a maximum. – Very efficient, but can only typically create a single type of object.
– Advances pointers as we allocate. – Doesn’t keep track of each allocation – frees everything together.
– Art assets
performance.
– Design assets
etc.
– Game entities
– Text-or-binary format: Simple structures with properties like floats, ints, strings, etc. – Binary-only custom format: E.g. DDS textures, WAV audio files, etc.
simple structures.
system
– Can use similar binding system to scripting – The better ones provide data reflection for marshalling
be the only option (e.g. DDS textures, WAV files).
certainly easier to:
– Look at, and – Check for differences between versions.
to convert the text files to binary through the asset pipeline.
– JSON, YAML, XML (if you must)
by name later.
– Store name in object data during load – Put in a hash table – Look up by name
// Find an animation! Name animName = “walk”; Animation* anim = animationsInventory->Find<Animation>(animName);
code or in data. For example:
– How should a monster react when you attack it? – What’s the maximum speed for a car when you drive it?
– Initial coding effort to parse data < time saved by quick iteration
the clients.
coding.