I'm reposting a version of this cause I think the issue would be well served as a separate post, instead of buried in my other thread.
The inconsistent behavior is that memory usage is accurate if a library is accessed as:
<class>.function();
but not via a pointer
<class>->function();
I created a library to demonstrate the difference between the two. I created a library, StealthMemory, which creates and initializes a byte array of 1024. To start off, I followed the example of access that was in RingBuffer (ADC library) example code (pointer access). I attached the library I created, which comes with the example.
I used arduino 1.6.5 and 1.6.8/teensyduino1.28
The inconsistent behavior is that memory usage is accurate if a library is accessed as:
<class>.function();
but not via a pointer
<class>->function();
I created a library to demonstrate the difference between the two. I created a library, StealthMemory, which creates and initializes a byte array of 1024. To start off, I followed the example of access that was in RingBuffer (ADC library) example code (pointer access). I attached the library I created, which comes with the example.
Code:
#include <StealthMemory.h>
//StealthMemory sm;
StealthMemory *sm;
void setup() {
/*this faithfully tracks memory usage in arduino IDE*/
//sm = StealthMemory();
//sm.initialize();
/*this does not track memory usage arduino IDE, reports no extra memory usage*/
sm = new StealthMemory();
sm->initialize();
}
void loop() {
}
I used arduino 1.6.5 and 1.6.8/teensyduino1.28