Memory Allocations and Garbage Collection #10839
Unanswered
zpif
asked this question in
Core Development
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using a third-party library (miniz, to read from Zip files) that needs to allocate memory. It helpfully provides callbacks to use instead of malloc(), free() and realloc() from the C library, so I decided to use Micropython's m_new(), m_free() and m_realloc() instead, to avoid having two heaps to worry about.
My issue is that apparently these allocations are treated as garbage, so when the garbage collection runs, the allocated memory becomes dangling pointers.
Now I wonder if I have to, e.g., add a new root pointer to my port, and to keep a list of all memories that I allocated.
Is that what I must do, or is there an easier way?
Beta Was this translation helpful? Give feedback.
All reactions