Available ELECTRON ASSET TRACKER RAM for malloc

is there a run-time way to get max available ELECTRON ASSET TRACKER RAM for malloc?

The build.particle reads back 20000 but it is said that is a buggy value and it’s more like 50k or 60k.

https://docs.particle.io/reference/firmware/photon/#freememory-
This might help.

But not all of that figure will be available for malloc() since it reports all free RAM, but malloc() can only allocate blocks in the heap section of that.
And then it needs to find a block big enough to fit in your desired block.
So you’ll never get around the need to check each malloc() attempt for success.

1 Like