Question

I'm using an external library which uses String.intern() for performance reasons. That's fine, but I'm invoking that library a lot in a given run and so I run into the dreaded

java.lang.OutOfMemoryError: PermGen space

Obviously I can use the JVM command-line -XX:MaxPermSize modifier, but that solution isn't very scalable. Instead, is there any way to periodically (between two "batches" of library calls) "flush" the interned string pool, i.e. empty the static table of strings held by the String class?

Was it helpful?

Solution

No. Just size permgen appropriately. It's no different to having to size the heap appropriately. Don't be afraid!

OTHER TIPS

Investigating further, I found this article, which seems to demonstrate that interned strings are still garbage collected. I guess that means that my problem here is a deeper one - the library I use must still hold a living reference to these strings :(

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top