-
Notifications
You must be signed in to change notification settings - Fork 362
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
Memory leak SunMoonCalc #144
Comments
We haven't verified ourselves yet but that's a pretty convincing bug report, thanks. |
Thanks, Marcel. EDIT: what I previously wrote here about ESP32 being able to recover from this is unfortunately not true. It does restart while an ESP8266 crashes without being able to restart. At least for the ones that I tested. |
Hallo Herr Stör,
if you don’t understand German, i will answer in poor english (as my english teacher belived to say).
Ich habe selbst ein Javascript für den Arduinbo angepast und anfangs auch mit dem exzessiven Speicherverbrauch zu kämpfen gehabt. https://lexikon.astronomie.info/java/sunmoon/sunmoon.html
Also Rekursionen und „reference by value“ waren ganz schöne Speicherfresser.
Es war mein erster Gehversuch in C.
Mittlerweile funktioniert es auf dem ESP8266 seit Jahren ganz brauchbar, aber ein paar Mal im Jahr liefert das Programm keine Werte für Mondaufgang / Monduntergang. Klingt trivial, die Lösung ist es nicht. Hier die Antwort des Verfasseres des original-Javascriptes (Ein vor allem in in Astronomie sehr kompetenter und hilfsbereiter Schweizer.)
Hallo Herr Barmettler,
ich hätte eine Verständnisfrage:
wenn man als Datum den 21.9.2017 (Rest kann auf Voreinstellung bleiben)
auf http://lexikon.astronomie.info/java/sunmoon/
einträgt, dann werden keine Mondauf-/-transit-/-untergangszeiten angezeigt.
Eigentlich müsste der Mond grob so gegen 8:05Uhr auf- und so gegen 20:08
Uhr untergehen.
Hallo Herr Detterbeck
das Problem liegt im Lösungsansatz der Funktion "RiseSet": die Zeit wird
basierend auf der Sternzeit berechnet, die allerdings kürzer als 24
Stunden und damit nicht eindeutig zuordbar ist. Ich habe dazu keine
Lösung in Vorbereitung. Man könnte weitere Iterationen machen um die
Mehrdeutigkeit zu erkennen.
Mit besten Grüssen
Arnold Barmettler
…-------------------------------------- . -------------------------
Arnold Barmettler, Dipl. Ing. ETH + + CalSky.com Services
Tel +41 32 511 77 72 <sip:0041325117772> + .
Naturfreundeweg 2
Fax +41 433 11 00 42 <sip:0041433110042> * .
CH-8135 Langnau am Albis
barmettler@calsky.com * Switzerland
----------------------------------------------------------------------
Also dachte ich, dass ich mir das Leben einfach mache und das SunMoonCalc Programm von Thingpulse verwende.
Das war zu einfach gedacht: Bis ich dem mit meinen beschränkten C-Kenntnissen das richtige rechnen beibringe und das Speicherfressen abgewöhne, such ich lieber nach einer Lösung im „Barmettlerschen“ Code oder lebe mit dem Fehler.
Mittlerweile gibt es viele Programme im Netz, die alle irgendwie aufeinander aufbauen und daher die gleichen Fehler haben. Ich denke auch, dass das Original Java-Script falsch rechnet, kann es aber derzeit nicht prüfen. Oder man macht es wie der Donald Trump: Wenn 10 republikanische Programme das gleiche rausbringen, dann muss der Mond wohl falsch aufgehen. So einfach ist das. ;o}
Spaß beiseite. Es gibt auch kluge Amerikaner: http://aa.usno.navy.mil/data/docs/RS_OneYear.php Form B benutze ich als Referenz für eigene Programme. Nachdem die Seite vom Militär betrieben wird, werden die ihre Programme schon x-fach geprüft haben.
Falls sie Interesse an meinem Arduino-Programm haben, kann ich es gerne schicken. Vielleicht ist es einfacher es mit etwas Objektorientierung aufzuhübschen und o.g. Iterationen einzubauen.
Ich hab noch ein vor Jahr(zehnt)en verfasstes Visual-Basic Programm (für Excel), das funktioniert komischerweise. Es basiert aber beim Mondaufgang auf Winkel und nicht auf Sternzeiten (soweit ich mich noch erinnern kann).
Wenn ich mal Zeit habe kram ich das wieder raus.
mit freundlichen Grüßen
Manfred Detterbeck
_________________________________________________________________
Kornburger Strasse 9
D-90530 Wendelstein
Pos: N 49°20.960 E011°06.755
Adresse in Google Maps <http://maps.google.com/maps?q=N49.349294+E11.112450+(Manfred%20Detterbeck)&t=h&hl=de&z=18>
Tel: +49 9129 3425
Mobil: +49 176 56895712
E-Mail privat: <mailto:manfred.detterbeck5@freenet.de> mailto:manfred.detterbeck5@freenet.de
E-Mail dienstlich: <mailto:Manfred.Detterbeck@siemens.com> mailto:Manfred.Detterbeck@siemens.com
_________________________________________________________________
Von: Marcel Stör [mailto:notifications@github.com]
Gesendet: Sonntag, 4. November 2018 16:31
An: ThingPulse/esp8266-weather-station
Cc: OrakelKSL; Mention
Betreff: Re: [ThingPulse/esp8266-weather-station] Memory leak SunMoonCalc (#144)
@OrakelKSL <https://github.com/OrakelKSL> let's keep these issues separate. I'm going to delete your comment (and mine), sorry.
This C++ class is a port from the popular Java class from here: http://conga.oan.es/~alonso/doku.php?id=blog:sun_moon_position. Any alleged calculation error is present there as well I assume?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#144 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/ARCDI5EXuWvMxol9VmsfTcHetf4MjbSzks5urwgXgaJpZM4YFgfB> . <https://github.com/notifications/beacon/ARCDIwXu7FnecR78nZb23FjUlbidIcH9ks5urwgXgaJpZM4YFgfB.gif>
|
@Leonos that's a weird one, indeed.
SunMoonCalc *smCalc = new SunMoonCalc(now - dstOffset, currentWeather.lat, currentWeather.lon);
moonData = smCalc->calculateSunAndMoonData().moon;
delete smCalc;
smCalc = nullptr; It must have something to do with the way those functions return their results as structs. |
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.
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:
Hardware
Adafruit's ESP8266 Feather Huzzah; Arduino core 2.4.2, Arduino IDE 1.8.5
8<------------------------ END BUG REPORT -------------------------------------
The text was updated successfully, but these errors were encountered: