Hi guys, I want to free a class instance from the memory in the c code. Can you please guide me how to do it? I have information about the QSTR of the instance. I had created the instance by calling mp_store_name function.
For a module, one can get information with mp_module_get(qstr_name_of_the_module), but have not seen similar function for a class instance.
Freeing an class instance from memory in the c code
-
- Posts: 12
- Joined: Tue Sep 27, 2016 2:29 pm
Re: Freeing an class instance from memory in the c code
Generally speaking you don't need to. The garbage collector will free it when appropriate.
If you know that there is nothing pointing to the object and you really want to free it, you can use m_del or m_del_obj (prototypes in py/misc.h)
The only time I recall seeing this is when an object is allocated and something fails in the constructor and the object is no longer needed.
An example is here: https://github.com/micropython/micropyt ... ain.c#L504
If you know that there is nothing pointing to the object and you really want to free it, you can use m_del or m_del_obj (prototypes in py/misc.h)
The only time I recall seeing this is when an object is allocated and something fails in the constructor and the object is no longer needed.
An example is here: https://github.com/micropython/micropyt ... ain.c#L504