[Microbit-Python] Micro python: heap memory tuning

Giovanni Giorgi jj at gioorgi.com
Sat Sep 17 02:50:32 EDT 2016


Hi,
 I am playing with micropython microbit implementation.
I have removed some modules from the compilation, thus reducing the final compiled hex
I'd like to understand if I can extend the python heap space too.
I found in mprun.c the following lines:
....
    mp_stack_set_limit(1800); // stack is 2k

    // allocate the heap statically in the bss
    static uint32_t heap[9692 / 4];
    gc_init(heap, (uint8_t*)heap + sizeof(heap));
....

How can I compute the magic value 9692?
For instance if I remove some static allocated code, how can I compute a new larger value?
Also the dynamic heap allocation commented how below, is usable or it is a "bad idea"?
....
    /*
    // allocate the heap using system malloc
    extern void *malloc(int);
    void *mheap = malloc(2000);
    gc_init(mheap, (byte*)mheap + 2000);
    */


--
Giovanni Giorgi
jj at gioorgi.com






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20160917/059cf911/attachment.html>


More information about the Microbit mailing list