Mininal Port's Garbage Collection

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Posts: 5
Joined: Tue Jul 23, 2019 4:45 pm

Mininal Port's Garbage Collection

Post by ferran.campos » Wed Nov 27, 2019 7:33 pm

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.

Posts: 539
Joined: Thu Apr 24, 2014 9:13 am

Re: Mininal Port's Garbage Collection

Post by stijn » Thu Nov 28, 2019 9:50 am

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.

Posts: 47
Joined: Tue Feb 19, 2019 10:22 pm

Re: Mininal Port's Garbage Collection

Post by pulkin » Thu Nov 28, 2019 3:58 pm

Does anything prevent you from looking into the stack trace and/or running gdb on it?

User avatar
Posts: 2052
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Mininal Port's Garbage Collection

Post by jimmo » Sun Dec 01, 2019 11:18 am

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.

Post Reply