Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory efficient, low overhead replacement for String in Java

After reading answers on this old question, I'm a bit curious to know if there are any frameworks now, that provide for storing large no.(millions) of small size(15-25 chars long) Strings more efficiently than java.lang.String.

If possible I would like to store represent the string using byte[] instead of char[].

My String(s) are going to be constants & I don't really require numerous utility methods as provided by java.lang.String class.

like image 836
Rajat Gupta Avatar asked Nov 16 '25 11:11

Rajat Gupta


1 Answers

Java 6 does this with -XX:+UseCompressedStrings which is on by default in some updates.

Its not in Java 5.0 or 7. It is still listed as on by default, but its not actually supported in Java 7. :P

Depending on what you want to do you could write your own classes, but if you only have a few 100 MBs of Strings I suspect its not worth it.

like image 145
Peter Lawrey Avatar answered Nov 18 '25 05:11

Peter Lawrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!