-
i'm actually not even sure how the garbage collector is working.
Well as long as the value is referenced by some variable it cannot be freed.
If you want to free memory locked byuncompressed_block
before variable goes out of scope you can assign it another value likeuncompressed_block=null
however you should also clear
raw_block
(andraw_ways
) as it is still referencing the uncompressed array toohowever all those functions defined at line https://github.com/wagnerf42/gps/blob/main/app.js#L339 capture
raw_ways
in its scope so this is tricky. now it gets freed oncemenu
goes out of scope (on line 361) as it references all those functions
hi,
i'm getting tight with my memory usage so I started profiling it a little bit.
i'm actually starting my app with a few menus and these guys require quite a lot of memory allocations: i need to decompress a few arrays using heatshrink.
now, after i select my entry in the menu i can safely free all this memory and live happily ever after.
i just need to keep a very tiny array i created in the callback.
however i'm not sure how to do that. i don't see how to wait in the main function for the menu to return so i usually launch my code in the menu entry's callback itself. if i do that however, all large arrays stay allocated. i tried to use a timeout to create a new task and return from the menu callback which works but does not free my memory.
i'm actually not even sure how the garbage collector is working.
i'm not sure i'm clear. my code is here : https://github.com/wagnerf42/gps/blob/main/app.js
i want to call the function on line 357 with the local street array and free the memory decompressed line 321.