You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Yes, a always got freed, and oops got the wrong reference count.

    Because of the way Espruino works, there are a lot of small allocations. For example 1+2 allocates 1, 2 and finally 3. Sure, those could be freed without reference counting, but when objects are involved it gets virtually impossible without it.

    What I really wanted to avoid was having code like this:

    for (var i=0;i<1000;i++) {
      SPI1.send([1,2,3]);
    }
    

    That had to pause in the middle of execution to garbage collect all the copies of the array [1,2,3]. At the cost of some execution speed, Espruino generally manages to be more predictable when it does execute :)

About

Avatar for Gordon @Gordon started