Skip to content
Discussion options

You must be logged in to vote

If you reduce mp_task_heap_size you can reserve the memory above for your C application/module's use. GC wil ignore any memory outside the start and end values passed to gc_init().

An alternative approach is to allocate a block of memory from the micropython heap and hold a reference to it as long as you need it so that it does not get gc-ed. If it is a large block, you should allocate soon after boot to avoid heap fragmentation. This way you can dynamically set the size of memory for your module (if that is useful for your use case).

Another approach is to allocate the memory in python code as a bytearray (or other type of array) and pass that to your C module to use. This has the conven…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@BrunoESP32
Comment options

Answer selected by BrunoESP32
Comment options

You must be logged in to vote
4 replies
@BrunoESP32
Comment options

@BrunoESP32
Comment options

@jimmo
Comment options

@BrunoESP32
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
ESP32
Labels
None yet
4 participants