Skip to content

Make garbage collector built on malloc / free implementation with pointer indirection #1168

@vitiral

Description

@vitiral

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    rfcRequest for Comment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions