Pergunta

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?

Foi útil?

Solução

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

Outras dicas

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 :(

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top