NeoTrellis RAM occupation problems

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
docteurSid
 
Posts: 1
Joined: Mon Apr 26, 2021 11:46 am

NeoTrellis RAM occupation problems

Post by docteurSid »

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- ... ree-memory:

Code: Select all

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:

Code: Select all

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”