Prior to Java9, string internally stored as character array, where 16 bits are required to store each character. By analyzing the data from different applications, it is clear that the string occupy most of the heap space and most of the string objects contain only Latin-1 characters which require 1 byte storage.
To solve this problem, Java changes the internal representation of the String class from a UTF-16 char array to a byte array plus an encoding-flag field. The new String class will store characters encoded either as ISO-8859-1/Latin-1 (one byte per character), or as UTF-16 (two bytes per character), based upon the contents of the string.
Reference
https://openjdk.java.net/jeps/254
Previous Next Home
No comments:
Post a Comment