Pitfalls of Handling Large String Objects in Java

Most Java developers know to be careful about String concatenation. But some argue that it is less important nowadays with improved JVM garbage collection efficiency. That might be true for small objects, but for large String objects, which is common when dealing with web services and xmls, developers need to be even more careful with String operations in general, and not just concatenation.

OOM in Production, Why?


I recently looked into an OutOfMemory exception in production and the culprit turned out to be the following code.