-
Notifications
You must be signed in to change notification settings - Fork 82
Memory leak when calling cron_next #28
Comments
Hi, thanks for the report! Sorry, I don't have cycles to dig this (and also don't have ESP dev env), if you find the cause for this - I will happily accept a PR. |
Thanks for the notice. In the mean time I am testing against several esp8266/Arduino core lib versions, just to make sure it is happening in all versions and if not, whether it may be a bug in their code. |
Found the culprit, but no idea yet how to patch it. So it must be in this section: Lines 106 to 124 in 2fa1646
|
Hi there, I guess the issue is with the function Furthermore, why is there this piece of code? if (tz)
tz = strdup(tz);
What do you think? |
M, I cannot see obvious flaws in this piece of code. It is obviously not a nice way to do On |
I'd like to point you to espressif/esp-idf#3046 - might be actual cause. But also beware: I'm not sure how temporarily changing TZ on dual-core ESP32 will behave. It might return invalid values, or even crash... Or work without problems. I did not dig so deep yet. But generally calling |
Hello there, we got a similar issue. Heap is filled with strings like:
Until now there is no proof that those strings are still allocated, but due to the out of memory hard faults it seems likely. I could not spot an obvious flaw in the Edit: |
Hi, I don't know about STM32 libraries, but cause might be the same: leak is not caused by |
Hello, It seems that setting the
|
Hello, "cron next" calls "cron mktime" twice, which in turn calls "cron mktime gm". The time zone is obviously set with each call with "getenv" and "setenv". I don't think this is nice, because according to my understanding, something like this is an initialization that belongs once at the beginning of a program. However, this part leads to the memory leak observed here. If the setting of the time zone is commented out (see below), "cron next" works without any disadvantages that I can see and without a memory leak! |
This project is no longer maintained, see its updated and extended fork in exander77/supertinycron repo, closing the issue to archive the repo. |
At this moment I really have no idea where it could be.
I have narrowed it down to calling the
cron_next
. The usedcron_expr
is every time the same.I'm running this code on an ESP8266, using the esp8266/Arduino platform (2.6.3)
The amount the free heap decreases is depending on the expression complexity when calling
cron_next
.For example
* * * * * *
decreases the heap by 64 bytes.*/2 * * * * *
decreases the heap by 80 bytes.Sometimes it is also decreased by 112 bytes.
Example of log output running the code below:
The ESP node is running a lot more, so that's why it sometimes does show a slight increase in free memory.
But as can be seen in the code segment below, the sampled free memory is just wrapping the call to
cron_next
.Part of my code calling the function and logging the heap decrease:
The object wrapper I made to keep the expression and the calls to this library all in one place:
Like I said, I really have not a clue where this memory leak should come from. It could also be something specific to esp8266/Arduino or even that I'm doing things completely wrong.
The text was updated successfully, but these errors were encountered: