Deduplicator java app12/26/2023 You are reading this object info from database or file.If you have a Class Employee Class Employee Why String Deduplication needed? Let’s See with an example: When they match, one String’s char array will be re-assigned to the char array of the second string and the unreferenced char array of the first string becomes available for GC.Īs we have seen using String intern is slow as well overhead we can use this feature this is fast as compare to the intern. When it detects another String object with the same hash code, it compares two strings char by char. The char array is not accessible and modified from outside, this means that char array can be used safely by multiple instances of String at the same time.ĭ eduplication may happen during minor GC, Garbage collector visits String objects and stores the hash value next to a weak reference of the char array. String class keeps string value in char array. The implementation used a fixed size ( default 1009, can be set using -XX:StringTableSize=N) hashtable so as the number entries grew, the performance became O(n).
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |