<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Memory Model on Code Log</title><link>https://codelog.me/en/tags/memory-model/</link><description>Recent content in Memory Model on Code Log</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 20 Jan 2015 14:05:51 +0800</lastBuildDate><atom:link href="https://codelog.me/en/tags/memory-model/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding the Java String.intern() Memory Model</title><link>https://codelog.me/en/posts/java-string-intern/</link><pubDate>Tue, 20 Jan 2015 14:05:51 +0800</pubDate><guid>https://codelog.me/en/posts/java-string-intern/</guid><description>&lt;p&gt;As you know, calling &lt;code&gt;string.intern()&lt;/code&gt; in Java first looks up the corresponding string in the string constant pool; if the string does not exist, it is created in the pool and then returned.&lt;/p&gt;
&lt;p&gt;The string constant pool is a fixed-size HashMap whose default bucket count is 1009; starting from Java 7u40, this default was increased to 60013. In Java 6, the string constant pool was located in the Perm space, and starting from Java 7 it was moved to the Heap space. Below, we use a test program to look at the memory allocation of the string constant pool under the two different versions, Java 6 and Java 7.&lt;/p&gt;</description></item></channel></rss>