You are reading a single comment by @fanoush and its replies.
Click here to read the full conversation.
-
Thanks a lot for your help! :)
I played withprocess.memory()
for a while on some toy code, but still no sure whatusage
andhistory
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,"history":6,"gc":0,"gctime":3.47900390625,"blocksize":16,"stackEndAddress":536929592,"flash_start":0,"flash_binary_end":443732,"flash_code_start":446464,"flash_length":524288} RAM Middle: {"free":2336,"usage":164,"total":2500,"history":11,"gc":0,"gctime":3.57055664062,"blocksize":16,"stackEndAddress":536929592,"flash_start":0,"flash_binary_end":443732,"flash_code_start":446464,"flash_length":524288} Hello, world! RAM After: {"free":2330,"usage":170,"total":2500,"history":19,"gc":0,"gctime":3.57055664062,"blocksize":16,"stackEndAddress":536929592,"flash_start":0,"flash_binary_end":443732,"flash_code_start":446464,"flash_length":524288}
If I understand the document correctly, then
usage
is the number of currently used blocks of RAM, andhistory
is the number blocks used by all the the commands (JS statements) until inclusive the current statement, right?
process.memory()
is probably the most important oneAlso check http://www.espruino.com/Internals
There is also E.dumpVariables or E.dumpFragmentation Also
trace(variable)
can dump a tree of everything referenced byvariable
.There is no heap, just variables. Also there is CPU stack growing down, the value can be seen in
process.memory().stackEndAddress
so0x20000000+0x10000-process.memory().stackEndAddress
can give size of currently(?) used stack.