java.lang.OutOfMemoryError while transforming XML in a huge directory

后端 未结 4 1323
闹比i
闹比i 2021-01-05 19:58

I want to transform XML files using XSLT2, in a huge directory with a lot of levels. There are more than 1 million files, each file is 4 to 10 kB. After a while I always rec

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 20:41

    I had a similar problem that came from the javax.xml.transform package that used a ThreadLocalMap to cache the XML chunks that were read during XSLT. I Had to outsource the XSLT into its own Thread so that the ThreadLocalMap cleared when the new Thread died - this freed the memory. See here: https://www.ahoi-it.de/ahoi/news/java-xslt-memory-leak/1446

提交回复
热议问题