• Ok, first check that you're using the latest version... Version 1v65 had a memory leak when receiving from Serial ports.

    And then, you should switch from using arrays to using a single string that you append.... Instead of arr.push(data); and var str = arr.join(""); just use str += data;

    Arrays in JavaScript are sparse, so each element has to store both the index and the value. In your case, it could be that for every character you are storing the index and a string, which will eat up the memory very quickly. It's much better to put all your information into one string - see http://www.espruino.com/Performance for more info.

    The reason it works at higher baud rates is that data contains more characters at a time. This means less entries in the array, which means less memory usage.

About

Avatar for Gordon @Gordon started