oppo-raw.ino consumes heap #87
Replies: 4 comments
-
Thank you very much for this observation! You are 100% correct, yes, that is all that needs to be done. (See docu that explicitly says that it needs to be manually deleted.) I have checked in the fix. Again, thank you very much! |
Beta Was this translation helpful? Give feedback.
-
OK I saw:
"Create an IrSequence
<https://bengtmartensson.github.io/Infrared4Arduino/classIrSequence.html> from
data in PROGMEM.
This must manually be deleted by the programmer."
but wasn't sure exactly how to do it but after some experimenting and
research I found several online refences which I didn't fully understand.
free(intro);//didnt work
delete [] intro; didnt work
delete intro;//worked
*I also saw in IrSequence.cpp*
IrSequence::~IrSequence
<https://bengtmartensson.github.io/Infrared4Arduino/classIrSequence.html#a7f005ca00f63f25956234173a87ba0bc>()
{
42 delete [] durations;
43 }
Can that be used somehow as well?
Regards
Jim
…On Fri, 27 Jan 2023 at 12:12, Bengt Martensson ***@***.***> wrote:
Thank you very much for this observation! You are 100% correct, yes, that
is all that needs to be done. (See docu
<https://bengtmartensson.github.io/Infrared4Arduino/classIrSequence.html#a0a450f4f43b1949dcae27789579afc8c>
that explicitly says that it needs to be manually deleted.) I have checked
in the fix.
Again, thank you very much!
—
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AETJBLQ6TG3VK5HWL3GPPB3WUO3T7ANCNFSM6AAAAAAUISH2WY>
.
You are receiving this because you authored the thread.Message ID:
<bengtmartensson/Infrared4Arduino/repo-discussions/87/comments/4796404@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
This is my current C++ favorite book. |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks for all that advice.
Regards
Jim
…On Fri, 27 Jan 2023 at 13:24, Bengt Martensson ***@***.***> wrote:
free(...) is for stuff that has been allocated with malloc, do not use
with C++ style new. delete is the normal way to dispose stuff that has
been allocated with new --- readFlash does new implicitly. delete[] is
for stuff created by new xyz[something], and only for that.
This
<https://www.amazon.co.uk/Tour-C-Bjarne-Stroustrup-ebook/dp/B0B8S35JWV/ref=d_pd_sbs_sccl_1_4/258-1055745-4931604?pd_rd_w=ctboL&content-id=amzn1.sym.e915a13f-380a-44c0-b87a-2bc42d7457b9&pf_rd_p=e915a13f-380a-44c0-b87a-2bc42d7457b9&pf_rd_r=S7RSTHN0RPQ02X0J01RC&pd_rd_wg=yL3xb&pd_rd_r=66abef15-60a4-48a9-9b3c-c1c3964bf705&pd_rd_i=B0B8S35JWV&psc=1>
is my current C++ favorite book.
—
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AETJBLSBKUMULWAKZFE24PDWUPECFANCNFSM6AAAAAAUISH2WY>
.
You are receiving this because you authored the thread.Message ID:
<bengtmartensson/Infrared4Arduino/repo-discussions/87/comments/4796960@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
In the example "oppo-raw.ino" the following routine consumes the heap on each pass:
`static void sendRaw(const microseconds_t intro_P[], size_t lengthIntro, const microseconds_t repeat_P[],
size_t lengthRepeat, frequency_t frequency, unsigned times) {
}`
I have added these lines at the end of the routine which cures the problem but as I am not an expert programmer I wonder if this is correct and all that needs to be done?
delete intro; delete repeat; delete ending;
Beta Was this translation helpful? Give feedback.
All reactions