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

后端 未结 4 1304
闹比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:31

    My usual recommendation with the Saxon s9api interface is to reuse the XsltExecutable object, but to create a new XsltTransformer for each transformation. The XsltTransformer caches documents you have read in case they are needed again, which is not what you want in this case.

    As an alternative, you could call xsltTransformer.getUnderlyingController().clearDocumentPool() after each transformation.

    (Please note, you can ask Saxon questions at saxonica.plan.io, which gives a good chance we [Saxonica] will notice them and answer them. You can also ask them here and tag them "saxon", which means we'll probably respond to the question at some point, though not always immediately. If you ask on StackOverflow with no product-specific tags, it's entirely hit-and-miss whether anyone will notice the question.)

提交回复
热议问题