A mobile app receives series of 4 bytes long packets. There can be about ~1M of those packets received in one session. The app can analyse them once all packets are received, so there is a need to store them somehow. I wonder what is the best approach in terms of memory size efficiency for Kotlin Multiplatform Mobile project.
I considered:
Common implementation for Android and iOS and use:
ByteArrayList<Long>- keep 2 packets in the biggest primitive -Long(8B) to reduce number of internal items in the list, hence reduce memory overhead consumed by each object.
Make an abstract collection and implement it for each platform. As an internal memory model use:
- Android:
ByteBufferorByteArrayorList<Long> - iOS (Swift):
ByteArrayorData
- Android:
Minimal memory usage is the most important factor.
What is the best approach in terms of memory consumption?