Closed
Description
See forum thread: http://forum.arduino.cc/index.php?topic=173718
A small test program which uses a small class, statically allocated, compiled for the Due under 1.5.2, takes:
Binary sketch size: 9,488 bytes (of a 524,288 byte maximum) - 1% used
Changing (only) to use the "new" operator to allocate the class dynamically, the sketch now takes:
Binary sketch size: 60,776 bytes (of a 524,288 byte maximum) - 11% used
It seems excessive to take 10% of available memory just to implement the operator new.
Adding these lines to the start of the sketch:
// new
void * operator new (size_t size) { return malloc (size); }
// placement new
void * operator new (size_t size, void * ptr) { return ptr; }
// delete
void operator delete (void * ptr) { free (ptr); }
The sketch now takes:
Binary sketch size: 11,296 bytes (of a 524,288 byte maximum) - 2% used
Only 1% more memory.
There must be some linking or other problem in the way the files implementing "operator new" are constructed.