RAM
Waspmote's microcontroller includes an 8 kB SRAM which is shared between initialized and uninitialized variables, the dynamic memory allocator, and the stack that is used for calling subroutines and storing local variables.
  • It is a good practice to delete variables which have already been used. This will avoid confusion, like "is this old or new?".
  • Also, once a vector has been used, it is good to delete all the fields in this vector, by writing 0's or voids, for example.
  • Avoid using strings so as to save memory. When printing debug messages use the Flash memory to allocate those messages:
1
USB.println("This is a message"); //WRONG
2
3
USB.println(F("This is a message")); //OK
Copied!
  • Avoid using dynamic memory allocation in order to prevent memory fragmentation. It is preferable to use controlled static variables.
  • It is possible to get the free memory by calling the function freeMemory:
1
USB.print(F("Free Memory:"));
2
USB.println(freeMemory());
Copied!
Last modified 2yr ago
Copy link