Page 1 of 1

Mininal Port's Garbage Collection

Posted: Wed Nov 27, 2019 7:33 pm
by ferran.campos
Hi, I have some problems with minimal port's gc_collect function.

First of all, I have been developing some code for the Micropython's minimal port in order to execute it in a stm32. Some of this code needs to run the gc_collect() function to avoid garbage to accumulate and occupy all my heap, leaving my board without any heap left and ending it's execution.

When I execute my code in a stm32 everything works fine, the heap is not fully occupied and the board is able to work indefinitely without running out of heap. However, when I compile the LINUX version of the Minimal port and run it, the gc_collect() generates a 'core dumped' exception.

I deduce that this function needs to be implemented, as it seems that it has to be adapted to every port.

Any ideas on how could I implement it or, maybe, make this function work in stm32 and LINUX?

Thank you.

Re: Mininal Port's Garbage Collection

Posted: Thu Nov 28, 2019 9:50 am
by stijn
I assume you'll have to copy the implementation from gccollect.c of the respective ports, so there's not one suingle function which can be used both for x64 and arm builds.

Re: Mininal Port's Garbage Collection

Posted: Thu Nov 28, 2019 3:58 pm
by pulkin
Does anything prevent you from looking into the stack trace and/or running gdb on it?

Re: Mininal Port's Garbage Collection

Posted: Sun Dec 01, 2019 11:18 am
by jimmo
The gc collection function is very arch and port specific.

Take a look at ports/unix/gccollect.c for an idea of what's necessary on Linux.