I have a bluetooth connection to a device that sends data as a byte array. The byte array is then changed to a string with new String(byte[], offset, bytecount). The problem is that data is received hundreds and hundreds of times and the garbage collection does not seem to be doing it's job because after about 1000 loops, I get an out of memory byte allocation error. The app starts to lag more and more as the loops increase as well.
Is there a way to free the memory of the new string object right after I use it or better yet, is there a way to change the byte array to a string or even a float without creating a new object?
Worse case, is there a way to give the app more memory so the error happens much later?