Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEMORY_PRINT_TOTALSIZE is off by one byte #5

Open
philj404 opened this issue Jun 4, 2021 · 0 comments
Open

MEMORY_PRINT_TOTALSIZE is off by one byte #5

philj404 opened this issue Jun 4, 2021 · 0 comments

Comments

@philj404
Copy link

philj404 commented Jun 4, 2021

This is for an Arduino UNO, which has 2048 bytes of total RAM.

Run the following sketch "GetMemoryTotalSize.ino":

#include <MemoryUsage.h>

// Simple example to report memory TOTAL size

void setup() {
    Serial.begin(115200);
    delay(1000);
    Serial.println(F( "Running " __FILE__ ", Built " __DATE__));
    Serial.println();

    MEMORY_PRINT_TOTALSIZE
}

void loop() {
    // User reads output from setup().
}

Your serial monitor generates an output something like this:

Running C:\Users\philk\OneDrive\Documents\Arduino\GetMemoryTotalSize\GetMemoryTotalSize.ino, Built Jun  4 2021

SRAM size:2047

NOTE: The RAM size reported is 2047 bytes (not 2048 bytes).

This is because the END macro returns the address of the last byte of RAM (not the byte after it). So beginning and end are inclusive limits.
It is harder to recognize problem because the start of RAM is at 0x100, so it's harder to tell where 2k byte RAM boundaries should really belong (particularly as decimal numbers).

See #4 for a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant