Support for Compressed Strings being Dropped in HotSpot JVM?

后端 未结 5 453
情深已故
情深已故 2020-11-29 19:35

On this Oracle page Java HotSpot VM Options, it lists -XX:+UseCompressedStrings as being available and on by default. However in Java 6 update 29, it is off by

5条回答
  •  失恋的感觉
    2020-11-29 20:13

    Just to add, for those interested...

    The java.lang.CharSequence interface (which java.lang.String implements), allows more compact representations of Strings than UTF-16.

    Apps which manipulate a lot of strings, should probably be written to accept CharSequence, such that they would work with java.lang.String, or more compact representations.

    8-bit (UTF-8), or even 5, 6, or 7-bit encoded, or even compressed strings can be represented as CharSequence.

    CharSequences can also be a lot more efficient to manipulate - subsequences can be defined as views (pointers) onto the original content for example, instead of copying.

    For example in concurrent-trees, a suffix tree of ten of Shakespeare's plays, requires 2GB of RAM using CharSequence-based nodes, and would require 249GB of RAM if using char[] or String-based nodes.

提交回复
热议问题