SRAM amount single object


#1

Is there a way to know how much SRAM a single object uses?


#2

Overflow your SRAM, write down the size. Add the object in question and recompile. Write down the new size. The difference is how much that object consumed.


#3

a 'tech' answer... if you know what the following means you can use it :wink:

unfortunately this is not trivial, as Axoloti inlines the code for performance - so when it comes to loading the binaries, all that is left is one large 'root' object (*)... i.e. your object does not exist as its own entity/size.

option 1 - objdump

we can inspect a patch .bss size using objdump, so size with and without the object in question

i.e.

  • remove object in question
  • compile Axoloti
  • use objdump to get size of root object

$ objdump -x build/xpatch.o | grep  _ZL4root
00000104 l     O .bss   00000838 _ZL4root

second number is the size (in hex, 0x00838 here) of the patch

  • now add your object back, and run objdump again , and note new size, and difference
    e.g. here, I increased the size of the delay line by 1024

$ objdump -x build/xpatch.o | grep  _ZL4root
00000104 l     O .bss   00001038 _ZL4root

so 0x1038- 0x838 = 0x800 = 2048 , (16 bit , so 2x1024 = 2048)

remember this is only the sram usage, sdram usage would be included in a different segment.

(*) theoretically, we can un-inline code segments but I don't think anyone else is doing this other than me ... if they do then you can look for that symbol.

option 2: read the code

just look at the code this will give you a pretty good idea... realistically, your only interested in large objects like buffers...

(note: Ive not reviewed the code in the upcoming release, this may or may not be changing)


#4

thx guys
@TheSlowGrowth this is what I do now ... looking for a simpler technique :slight_smile:
@thetechnobear ... no simpler way?
It would be nice to have the sdram size in the description of every object.


#5

no, otherwise, i would have given it to you :wink:

sdram, is different again btw.

generally, objects only take up a bit of sram, its only things like delay/tables etc that use significant memory, and then you specify it... so you kind of know the overall footprint.... and generally the solution is to move to sdram variants, so you need to then find these objects anyway.

dont get me wrong, I know it would be nice, and perhaps when we 'go live' we could report the current patch sram usage, so at least as you can build it, you can see it going up.

... also I think there is a change in the new release which might help, but Ive not looked close enough to see exactly what its reporting to say it will solve your issue.