• Sun 2020.04.19

    I need to monitor the number of blocks a user var requires in memory. I need to extract or view
    the contents of that var, using the reference that trace provides.

    Using trace,

    http://www.espruino.com/Reference#l__glo­bal_trace

    I'm able to view it's ID and space utilized: #348 and #531

         #348[r1,l2] Name String [1 blocks] "\xFFcod"        #531[r1,l0] FlatString [137 blocks] "console.log( \"    \" );\n  console.log( \"JsVars  Last:\
    
    

    What I am after is how to get the value #531 and it's contents. It takes up 137 blocks.

    Pairing down, now that I know the ID \xFFcod of the var

    >trace(["\xFFcod"]);
    #990[r0,l1] Array(1) [
      #986[r1,l2] Name Integer 0    #989[r1,l0] String [1 blocks] "\xFFcod"
    ]
    

    But a curious response emerges, the reference value changes from #348 to #990, but it is the same location in memory?



    Q1: Why does the refrence value change and what is that value exactly?
    Q2: Wht is the meaning of 'r0' and 'l1' and compared to 'r1' and 'l2' ?

    Using getSizeOf()

    >E.getSizeOf(["\xFFcod"], 2)
    =[
      {
        name: "0",
        size: 2 }
     ]
    >
    
    >E.getSizeOf(["\xFFcod"], 1)
    =[
      {
        name: "0",
        size: 2 }
     ]
    
    >E.getSizeOf(["\xFFcod"], 0)
    =3
    > 
    



    Q3: What is the 'name' attribute refereing to?
    Q4: What are the return values here as they don't seem to be the actual blocks as returned in a trace request?
    Q5: How to get the value #531 and it's contents using trace() ?

    Thank you in advance. . . .

About

Avatar for Robin @Robin started