DMAMEM storage space

KeithB

Member
I am working on a Knowledge base project and would like to store an index in DMAMEM which links to a record number on an SD card.

I have used the following in my code
DMAMEM word KBIndex[50000];

When I compile this, this single line uses 200000 bytes of space in RAM2 not the 100000 bytes that I was expecting.
Does this mean a word occupies 4 bytes of memory, it the 2 bytes expected.
I am using Teensy 4.1

Any comments welcome please.
Keith
 
Thanks, that works.
on a similar theme, if I use byte, char, and uint8_t, I get a usage of 49984 not the expected 50000 hence 16 bytes short. Any ideas why this would be the case?
 
Can you show your program? I don’t know how you’re getting the size. Are you using the sizeof operator?
 
I am changing the single line in the code…
DMAMEM byteKBIndex[50000];

then compiling and viewing the Compile stats where it shows the usage for RAM1 and RAM2.
 
I believe I’ve just worked out what is happening. When compiling, the compiler is using 32 byte boundary for RAM2 Reporting. This is why if I use byte for the variable type it still allocates the capacity correctly, but because there is some spare unused bytes due to the upto 32 byte buffer, then the addition capacity allocated is less than the expected 50000.

putting it another way. Before adding that line, there is 16 bytes free in the RAM2 allocation. After this line has been added, an additional 49984 bytes are allocated, thus making a total of 50000 as expected.

thanks for the help, hope explanation this makes sense.
 
I’m glad you figured it out. I rely on things like what I put in post #5 to get the actual sizes of objects. The teensy_size output only gives you a rough idea.
 
Back
Top