How can I destroy a link from a String pool in Java?

Lines are immutable. When I declare:

String a = "abc";
String a1 = "abc";

Both objects belong to one place. So, how can I destroy this "abc" link from the string pool?

My use case is that I am developing a hardware application with less memory, and for this I need to clear the links from the string pool to save memory.

+4
source share
1 answer

No, usually you cannot "destroy a link from a string pool in Java" manually.

, , , , . Java 6 PermGen - , . , PermGen , . Java 6 - PermGen. PermGen . -XX: MaxPermSize = N. .

Java 7 - . , . , .

, -XX: StringTableSize = N. , - XX: + PrintStringTableStatistics JVM. , .

JDK jmap, .

jmap -heap process_id

:

jmap -heap 18974

, " xxxxxx , xxxxxx."

String , . , String, , , , , , . , . , (, Class.forName(...)), , . , String , , , GC'ed.

+5

Source: https://habr.com/ru/post/1649130/


All Articles