Acknowledged

ByteArray addAll() not Memory Efficient

When using the addAll() method of Lang.ByteArray, peak memory usage implies that the ConnectIQ framework is doubling the size of the array being appended to instead of extending it by the size of the appended array.

For example, let's say we create a 1K byteArray called myArray and run the following code starting with an empty byte array, longByteArray:

while(longByteArray.size() < 32768) {
    longByteArray.addAll(myArray);
}

An efficient implementation would grow peak memory usage by ~1K more than longByteArray.size(). Instead, we see peak memory usage growing with longByteArray.size() * 2 + 1024.

It may also be worth noting that the Monkey C extension for Visual Studio code will time out as the array grows if a developer sets a breakpoint on the addAll function above while the watch window is open to longByteArray.

Parents
  • Unfortunately, there is many places (e.g. dictionary, settings) where ciq runs that way and don't expect it will be fixed soon or ever.

    Maybe solution is writing your own class that emulates system's array.

    BTW, does this big array have dynamic or static data?

Comment
  • Unfortunately, there is many places (e.g. dictionary, settings) where ciq runs that way and don't expect it will be fixed soon or ever.

    Maybe solution is writing your own class that emulates system's array.

    BTW, does this big array have dynamic or static data?

Children
No Data