• process.memory() is probably the most important one

    Also check http://www.espruino.com/Internals
    There is also E.dumpVariables or E.dumpFragmentation Also trace(variable) can dump a tree of everything referenced by variable.

    There is no heap, just variables. Also there is CPU stack growing down, the value can be seen in process.memory().stackEndAddress so 0x20000000+0x10000-process.memory().stac­kEndAddress can give size of currently(?) used stack.

  • Thanks a lot for your help! :)
    I played with process.memory() for a while on some toy code, but still no sure what usage and history mean.
    For example:

    const ramBefore = process.memory();
    const helloWorld = `${JSON.stringify(process.memory())} Hello, world!`;
    const ramAfter = process.memory();
    
    print(`RAM Before: ${JSON.stringify(ramBefore)}`);
    print(`RAM Middle: ${helloWorld}`);
    print(`RAM After: ${JSON.stringify(ramAfter)}`);
    

    Result:

    RAM Before: {"free":2383,"usage":117,"total":2500,"h­istory":6,"gc":0,"gctime":3.47900390625,­"blocksize":16,"stackEndAddress":5369295­92,"flash_start":0,"flash_binary_end":44­3732,"flash_code_start":446464,"flash_le­ngth":524288}
    RAM Middle: {"free":2336,"usage":164,"total":2500,"h­istory":11,"gc":0,"gctime":3.57055664062­,"blocksize":16,"stackEndAddress":536929­592,"flash_start":0,"flash_binary_end":4­43732,"flash_code_start":446464,"flash_l­ength":524288} Hello, world!
    RAM After: {"free":2330,"usage":170,"total":2500,"h­istory":19,"gc":0,"gctime":3.57055664062­,"blocksize":16,"stackEndAddress":536929­592,"flash_start":0,"flash_binary_end":4­43732,"flash_code_start":446464,"flash_l­ength":524288}
    

    If I understand the document correctly, then usage is the number of currently used blocks of RAM, and history is the number blocks used by all the the commands (JS statements) until inclusive the current statement, right?

About

Avatar for fanoush @fanoush started