1

Intention is to reduce old gen size in order to lower gc pauses.

In my understanding Chronicle Map will store objects in native space and (starting from java 8) String#intern will do the same because interned string are in metaspace.

I was curious whenever I need to use chronicle map, or it's ok to stick with intern method.

leventov
  • 14,760
  • 11
  • 69
  • 98
Petro Semeniuk
  • 6,970
  • 10
  • 42
  • 65
  • 1
    Interned strings are stored in Java Heap in JDK 8+ just like regular strings, though a string table is in Metaspace. I doubt that strings are the reason for long GC pauses. Why do you think so? How many strings are there, how much space do they occupy and what is their average lifetime? – apangin Jul 09 '15 at 06:37
  • I have 200Mb of strings. Lifetime varies form one hour to one week. – Petro Semeniuk Jul 09 '15 at 09:25
  • I'm pretty sure this isn't a problem. 200MB is not much. Our high-loaded projects have 20+ GB heaps with GC pauses under 180 ms. What goals do you want to achieve? As to original question, there is no correct answer because off-heap maps and String.intern have completely different purposes. – apangin Jul 09 '15 at 10:28
  • Oh, sorry. Out Xmx is 512Mb. We are running bunch of linux container each with small set of java processes inside. I understand that offheap and intern are for different purposes, just was thinking that intern would move string to native space. Anyway. given that that's not the fact I'll remove question (it's invalid after all). – Petro Semeniuk Jul 09 '15 at 12:53

1 Answers1

3

ChronicleMap couldn't serve as a direct replacement of String.intern() because java.lang.String instances are always on-heap. So you won't actually win anything, even storing strings in ChronicleMap, because before using them you will deserialize them to on-heap object.

ChronicleMap as a data structure, (not necessarily with Java implementation, maybe C++) indeed could be used for some sort of caching textual data, especially inter-process. But I suspect it is very far from what you are seeking. For example on Java side, it will require a separate value class (not String and not StringBuilder), implementing CharSequence at best.

Also, very likely you don't need intern, but deduplication that could be much more effective, see java.lang.String Catechism talk, "Intern" section.

leventov
  • 14,760
  • 11
  • 69
  • 98