uniVocity / univocity-parsers

uniVocity-parsers is a suite of extremely fast and reliable parsers for Java. It provides a consistent interface for handling different file formats, and a solid framework for the development of new parsers.
905 stars 249 forks source link

The headers cache (StringCache) cause a memory leak #515

Open yishaic opened 1 year ago

yishaic commented 1 year ago

As described in #326 , there's a memory leak in the StringCache class, because the stringCache map values accumulate over time. Commit https://github.com/uniVocity/univocity-parsers/commit/43bed5110e75497fb2ded96912a87c4a9d0841fd was supposed to fix it, but it didn't - as it fixed only the put method, which isn't used in practice. The correct method to fix is get. We encountered this in our application - this leads to a very high GC.

An example of our heap dump: 1: 11186 6767425504 [B 2: 19409747 2161391776 [C 3: 19100605 764024200 java.lang.ref.SoftReference 4: 19153192 612902144 java.util.concurrent.ConcurrentHashMap$Node 5: 19409844 465836256 java.lang.String