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

Unknown RAM consumption source #45

Closed
yoann-dufresne opened this issue Jun 10, 2021 · 1 comment
Closed

Unknown RAM consumption source #45

yoann-dufresne opened this issue Jun 10, 2021 · 1 comment

Comments

@yoann-dufresne
Copy link

Hi there,

I'm working on a alt ctrl game using 6 independant NeoTrellis keyboards.
In this project I'm using an arduino nano with 2KB of SRAM.

After a few days I raised multiple segfaults due to collisions between stack and heap.
I optimized my code and now around 500B of RAM are available (still not enought for some usages).

I had a look at the NeoTrellis lib and I found a strange behaviour when I'm initializing neotrellis
The following code using the freeMemory function from here https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory:

    for (int i=0 ; i<6 ; i++) {
      Serial.print("Before NeoTrellis init ");Serial.println(freeMemory());delay(10);
      this->trellis = new Adafruit_NeoTrellis(addrs[i]);
      Serial.print("After NeoTrellis init ");Serial.println(freeMemory());Serial.println();delay(10);
    }

is producing the following output:

    Before NeoTrellis init 2295
    After NeoTrellis init 1269
    Before NeoTrellis init 1203
    After NeoTrellis init 1130
    Before NeoTrellis init 1064
    After NeoTrellis init 991
    Before NeoTrellis init 925
    After NeoTrellis init 852
    Before NeoTrellis init 786
    After NeoTrellis init 713
    Before NeoTrellis init 647
    After NeoTrellis init 574

As you can see there is a huge RAM consumption when I created the first object (around 1KB) but small ones for the other objects (~75B).
I tried to find the source of the 1KB consumption but I'm in a dead end for now.

Do you have any idea of what causes this huge memory allocation ?

In case you need it, my full code is here (init in the class def cube.cpp):
https://github.com/yoann-dufresne/project-3
And here is a picture of the controler (for curious people :) ):
https://photos.app.goo.gl/YSnD6Wnm1GGsG3nm8

@ladyada
Copy link
Member

ladyada commented Jun 10, 2021

that isnt unusual, there can be RAM shared between the objects due to the underlying i2c connection. you will need to upgrade to a larger processor!

@ladyada ladyada closed this as completed Jun 10, 2021
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

2 participants