Memory management

General

Codnpix

5 years ago

Hi, 

I'm starting to design game a little more ambitious than all I tried before, and I'm facing that the memory question with the Gamebuino META is still quite unclear for me. 

So I have a bunch of questions that should help me to get my head clear and concieve my game the right way  : 

What part of the compiled code exactly is loaded into the RAM, and what part is loaded is the flash memory ? For example if I store a bank of image assets in a "images.h", and then I use them to provide a Sprite class or a Map class or whatever, how can I keep an eye on memory occupation ? 

And for example if I load an image in gb.display that is wider than the screen (say much wider), I'm not sure if only a part of the whole image is buffered into the RAM and then swaped as needed (if I move camera for example), or if the whole asset if loaded.

I don't know if those questions are actually relevants but as I said the memory problem is still unclear for me, so thank you if someone can help me to update a little my vision :) !

Thanks.

dreamer3

NEW 5 years ago

What part of the compiled code exactly is loaded into the RAM

None typically.  The address space on this CPU includes the flash so program code is read and executed from flash - and the same with data (images, sprites, etc).  Most of the built-in graphics routines if you're loading an image that's been compiled into flash then the only memory used is to keep track of the image metadata (it's frame, width, height, pointer to the data in flash, etc).

And for example if I load an image in gb.display that is wider than the screen (say much wider), I'm not sure if only a part of the whole image is buffered into the RAM

The largest "buffer" is the "VRAM" or buffer used for the screen itself.  So depending on your graphics mode that is a large chunk... so if you draw something to screen it's read from flash and then written to the "VRAM" so that it appears on the screen.  Again other than metadata the full image shouldn't be taking up a lot of space in memory.

You an also allocate images directly in RAM if you want to do so and the pointer to the image data will then point to a large piece of RAM, not flash.... but that's only if you choose to do so.

jicehel

NEW 5 years ago

Someone could explain fully the recipes of the META Memory, with a memory map like schemes below ?
(Draws below are just example, not matching with META) 

 Résultat de recherche d'images pour "Memory map of an arduino system"


or

SAMD21 Memory Map

I think it's could be a good start point to explain how memory works, we could define the differents types of memory and show what go in the differents zones and how to use wich / know how many space is free, asw...

Sorunome

NEW 5 years ago

The meta actually uses a samd21, so the second image you posted is exactly the memory map of the meta

Codnpix

NEW 5 years ago

Ok I'll try to puzzle this out then... thanks !