Trouble with Arduino - "Please select a port before upload"

Hi @Chris_Woods!

malloc() and free() are generally avoided on the resource constrained Arduino platform.

We have so little memory to work with that is it very easy to run out, so it is nice to allocate all the memory you need statically so at least you can see that you are running out at compile time.

I even avoid putting anything too big to fit into a register on the local variable stack just to avoid hard to track down out of memory bugs. You can use the static keyword to keep the scoping of a local variable inside the code block while still having it get allocated from the static memory pool (just remember to initialize its value manually inside the block).

Make sense?

1 Like