• You can just use Graphics normally or pass the variable g in if you want to be able to draw to Graphics?

    So using g as a global var is fine, that's what I do at the moment.

    so you can always create it 'offline' and then use btoa to create a base64 encoded string and use that in your code (a bit like is done with images)

    like this?

    
    //var map = [13, 39, 114, 25, 51, 102, 19, 27, 108, 61, 33, 66, 35, 29, 92, 49, 57, 78, 47, 5, 80, 59, 17, 68, 55, 9, 72, 11, 23, 116]; 
    //mapb = btoa(E.toString(map));
    var mapb = "DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd­0";
    console.log(atob(mapB)[0].charAt(0));
    // 13
    
    

    compare usage

    >process.memory()
    ={ free: 2458, usage: 42, total: 2500, history: 1,
      gc: 0, gctime: 4, blocksize: 16 }
    >var map = [13, 39, 114, 25, 51, 102, 19, 27, 108, 61, 33, 66, 35, 29, 92, 49, 57, 78, 47, 5, 80, 59, 17, 68, 55, 9, 72, 11, 23, 116];
    =[ 13, 39, 114, 25, 51,  ... 9, 72, 11, 23, 116 ]
    >
    >process.memory()
    ={ free: 2426, usage: 74, total: 2500, history: 17,    // 30
      gc: 0, gctime: 3, blocksize: 16 }
    >delete map
    =true
    >process.memory()
    ={ free: 2458, usage: 42, total: 2500, history: 19,
      gc: 0, gctime: 5, blocksize: 16 }
    >var mapb = "DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd­0";
    ="DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICx­d0"
    >process.memory()
    ={ free: 2453, usage: 47, total: 2500, history: 25,     // 5 !
      gc: 0, gctime: 0, blocksize: 16 }
    > 
    

    So using base64 encoded string is a real memory saver !

About

Avatar for MaBe @MaBe started