Vitaly Sazanovich created BATIK-1332: ----------------------------------------
Summary: Memory leak in org.apache.batik.ext.awt.image.rendered.TileCache.cache Key: BATIK-1332 URL: https://issues.apache.org/jira/browse/BATIK-1332 Project: Batik Issue Type: Bug Affects Versions: 1.14 Reporter: Vitaly Sazanovich Attachments: image-2022-08-19-23-57-52-386.png I'm using Batik to convert SVG to PNG. My Java code is: {code:java} public byte[] svg2png(byte[] svgBytes, float width, float height) throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); TranscoderInput transcoderInput = new TranscoderInput(new ByteArrayInputStream(svgBytes)); TranscoderOutput transcoderOutput = new TranscoderOutput(byteArrayOutputStream); PNGTranscoder pngTranscoder = new PNGTranscoder(); pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH, width); pngTranscoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, height); pngTranscoder.transcode(transcoderInput, transcoderOutput); transcoderInput.getInputStream().close(); transcoderOutput.getOutputStream().close(); byteArrayOutputStream.flush(); byteArrayOutputStream.close(); return byteArrayOutputStream.toByteArray(); } {code} I use Spring Boot and the conversion runs in the same http request. I started to get OOM after many conversions. So I made a heap dump and used JProfiler to analyze it: !image-2022-08-19-23-57-52-386.png! The solution I have found so far (workaround) is: {code:java} } finally { try { TileCache.setSize(0); TileCache.setSize(2); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } {code} Setting size to just 0 causes a null pointer exception on the next run. It looks like the cache needs some size greater than 0. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: batik-dev-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-dev-h...@xmlgraphics.apache.org