Skip to content

Memory leak SunMoonCalc #144

Closed
Closed
@Leonos

Description

@Leonos

Is anyone else getting this?

8<------------------------ BUG REPORT -----------------------------------------

Actual behavior

Every run of
SunMoonCalc smCalc = SunMoonCalc(1541023330, 52.520008, 13.404954);
const SunMoonCalc::Result result = smCalc.calculateSunAndMoonData();

takes around 2500 bytes from memory and soon nothing is left. See Serial output.

1541052141
32592
Sun
1541052141
30080
Sun
1541052141
27568
Sun
1541052141
25056
Sun
1541052141
22544
Sun
1541052141
20032
Sun
1541052141
17520
Sun
1541052141
15008
Sun
1541052141
12496
Sun
1541052141
9984
Sun
1541052141
7472
Sun
1541052141
4960
Sun
1541052141
2448

Exception (29):
epc1=0x4020576f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000


Test code

https://github.com/ThingPulse/esp8266-weather-station/tree/master/examples/SunMoonCalcDemo
The example (SunMoonCalcDemo.ino) brought back to absolute minimum, moving the calculation from setup() to loop(), demonstrates this behavior:

#include "SunMoonCalc.h"

void printResult(SunMoonCalc::Result result) {
  Serial.println("Sun");
  Serial.println(result.sun.rise);
}

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println();
}

void loop() {
  if (millis() % 5000 == 0) {
    SunMoonCalc smCalc = SunMoonCalc(1541023330, 52.520008, 13.404954);
    const SunMoonCalc::Result result = smCalc.calculateSunAndMoonData();
    printResult(result);
    Serial.println(ESP.getFreeHeap());
  }
}

Hardware

Adafruit's ESP8266 Feather Huzzah; Arduino core 2.4.2, Arduino IDE 1.8.5
8<------------------------ END BUG REPORT -------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions