[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-hotspot-gc-use
Subject: Re: YGC time increasing suddenly
From: "Bernd Eckenfels" <bernd-2013 () eckenfels ! net>
Date: 2013-12-21 19:45:46
Message-ID: op.w8gjukm5tc8ri4 () eckenfels02 ! seeburger ! de
[Download RAW message or body]
Am 21.12.2013, 17:15 Uhr, schrieb Luciano Molinari <lucmolinari@gmail.com>:
> I noticed that many Strings in the heap are equals..shouldn't JVM keep
> only different Strings and re-use the equals?
When a string is interned (all constants in your classes are interned)
then there is only one instance for a string. However if you (or a
library) construct a new string from bytes/characters then it will not be
automatically interned and therefore created with multiple instances
(basically if you use "new String" you get what you ask for :)
You can use .intern() on a String to get its unique instance, but be sure
to do this only for the most common/often used strings. This does
essentially a hash lookup, so it is most often not a good idea to do it
(unless you know you keep them around for long and/or equal() them very
often. (For example it sometimes make sense to intern() all element names
of Dom Trees but not the (too many different) values).
Gruss
Bernd
--
http://bernd.eckenfels.net
_______________________________________________
hotspot-gc-use mailing list
hotspot-gc-use@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic