0

NeoTrellis RAM occupation problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NeoTrellis RAM occupation problems

by docteurSid on Wed Jun 09, 2021 2:51 pm

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:
Code: Select all | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
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

docteurSid
 
Posts: 1
Joined: Mon Apr 26, 2021 11:46 am

Please be positive and constructive with your questions and comments.


cron