JSVar revisited

Posted on
  • I'm trying to understand the memory management of Espruino.

    Puck has 64k RAM of which ~11 kbyte are reserved for softdevice and ~37kbyte are reserved at compile time (data + bss). In turn 32kbyte of bss are the 2000 JSVars. Therefore 16k are left for heap and stack.

    Heap seams to be 8k (0x2000bcd0 - 0x2000bcd0).
    Stack steams to be 16k, 8k shared with heap (0x2000bcd0 - 0x20010000).

    Are my calculations correct? Does any one know how much stack and heap is occupied at runtime?

  • Yes, that sounds about right. Espruino doesn't actually use heap at all, and I don't believe the softdevice does either - since stack grows into heap it's basically no heap and 16k stack.

    That's playing it super safe though, so at some point I may raise the amount of JSVars and reduce the available stack a little.

    Because the interpreter parses as it runs, it does tend to use a little more stack - especially with recursion. Generally it's not that bad though, and there are checks in place to try and ensure that JS code execution errors before the stack is exhausted.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

JSVar revisited

Posted by Avatar for AntiCat @AntiCat

Actions