This is a point that was brought up in the tinymem forum thread, where @pfalcon said:
Making uPy GC pluggable, so it can work with system heap (or any external memory manager) is a worthy aim to follow.
This issue is meant to address this, while simultaneously addressing a separate issue associated with the tinymem library -- that it uses pointer indirection to do it's defragmentation, and therefore all calls to pointers need to be wrapped in a tm_void() function call (in some way)
The way to solve this would be:
- make the underlying structure of the memory manager use a macro like
base_alloc and base_free that could be adjusted depending on the memory manager used
- have all pointers pass through macros. So, for example, instead of saying
uint8_t *dynamically_allocated_pointer you would say memptr_uint8_p(index) -- which would convert it to a pointer for you.
This is necessary to plugin into custom memory allocators, like the one I am developing for uPython, the tinymem memory manager
This is a point that was brought up in the tinymem forum thread, where @pfalcon said:
This issue is meant to address this, while simultaneously addressing a separate issue associated with the tinymem library -- that it uses pointer indirection to do it's defragmentation, and therefore all calls to pointers need to be wrapped in a
tm_void()function call (in some way)The way to solve this would be:
base_allocandbase_freethat could be adjusted depending on the memory manager useduint8_t *dynamically_allocated_pointeryou would saymemptr_uint8_p(index)-- which would convert it to a pointer for you.This is necessary to plugin into custom memory allocators, like the one I am developing for uPython, the tinymem memory manager