I am currently representing 128-bit integers in J2ME (which need to be created tens of millions of times) with objects holding a new int[4]. Is this reasonably less efficient than simply using 4 individual variables?
If you have "tens of millions" of small arrays, then you have tens of millions of the array object overhead.
A int[4] would take a reference value (4 bytes), and an array (16 bytes overhead), so 10 million values would use 200 Mb extra space. If you run Java with lots of memory, so compressed OOPS cannot be used, the extra space use is higher.
To store a 128-bit value, I would recommend using two long fields.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With