From 5f4ea9ac5dd50dadd6523909c458be5452b2ff55 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sat, 25 May 2024 01:10:23 +0200 Subject: [PATCH] reduced memory amount for network image reduced also the number of memory allocation for image storage --- source/net/yacy/visualization/RasterPlotter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/net/yacy/visualization/RasterPlotter.java b/source/net/yacy/visualization/RasterPlotter.java index 9bf29d206..2bac51836 100644 --- a/source/net/yacy/visualization/RasterPlotter.java +++ b/source/net/yacy/visualization/RasterPlotter.java @@ -929,9 +929,9 @@ public class RasterPlotter { public ByteBuffer exportPng() { try { - final ByteBuffer baos = new ByteBuffer(); - byte[] pngbytes = pngEncode(1); + byte[] pngbytes = pngEncode(9); if (pngbytes == null) return null; + final ByteBuffer baos = new ByteBuffer(pngbytes.length); baos.write(pngbytes); baos.flush(); baos.close(); @@ -1000,7 +1000,7 @@ public class RasterPlotter { final int height = image.getHeight(null); final Deflater scrunch = new Deflater(compressionLevel); - ByteBuffer outBytes = new ByteBuffer(1024); + ByteBuffer outBytes = new ByteBuffer(1024 * 300); // avoid frequent resizing of the ByteBuffer final OutputStream compBytes = new BufferedOutputStream(new DeflaterOutputStream(outBytes, scrunch, 2048, false), 16384); int i = 0; for (int row = 0; row < height; row++) {