Solution for oversize of dynamic memory

Hi

I try to compile the file in this link GitHub - Lawmate/BQ4050: Library for basic interfacing with BQ4050 battery fuel gauge from TI .

But I got an error as below:

Global variables use 4,768 bytes (232%) of dynamic memory, leaving -2,720 bytes for local variables. Maximum is 2,048 bytes.

Please advise to address that problem.

Rgds
Nazri

nazri2020:
I try to compile the file in this link https://github.com/Lawmate/BQ4050 .

But I got an error as below:

Global variables use 4,768 bytes (232%) of dynamic memory, leaving -2,720 bytes for local variables. Maximum is 2,048 bytes.

You do not mention what Arduino board you use, but as the error message mentions a “maximum of 2048 bytes” it could be a ATmega328 device (like Arduino UNO, Nano, Mini).

When I take a look at your link, I find a long list of “MCU” (micro controller units) like Atmega328, Atmega32u4, ESP8266, ESP32 and more. But most of them have state “not tested”.
The only one with state “Tested Works” is Teensy 3.2.

Teensy 3.2. has a lot more flash memory and RAM memory than Arduino UNO (ATmega328).

Possible solutions:

  • Get the device this project will work with (Teensy 3.2.)
  • Get a library that works with your device (UNO maybe)
  • Try to modify the library so it will work with your device.

It would also work with a Mega as that has 8K of dynamic memory.