-
Hello. Firstly, excellent library! Thanks 🧡 . I'm wondering if, when using list, I need to de-allocate or destroy the list or it's contents? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi, thanks for the feedback 😄 Memory AllocationThis library is using dynamic memory allocation with
|
Beta Was this translation helpful? Give feedback.
-
Thanks @nkaaf for taking the time to reply.
Amazing. Your work has paid off. Working through the examples I have found Arduino List to be super comfortable to use.
On this example you have used this clear() func. That makes sense to me in the context of the setup() {} function, which is run once. In the case of the loop() {}, when shall I use the clear() func? If the Arduino receives an unexpected power outage or I fail to catch a powerdown and do not implement clear(), will I have cause a leak? |
Beta Was this translation helpful? Give feedback.
Hi, thanks for the feedback 😄
Memory Allocation
This library is using dynamic memory allocation with
malloc
andnew
, therefore the raw data of the lists are saved on the heap (internal references to the content on the stack). The list is saved on the stack or the heap, depending on your creation of the list (new
-> heap; static creation (like examples) -> stack).new
/delete
The approach of using
new
is working in the context of an Arduino program (because of a custom override ofnew
anddelete
) or standard C++ program (and probably more software architectures which I haven't testes). It is not working when avr-gcc is used (e.g. in Microchip Studio). Until I dealt with your question, I was…