Skip to content

Commit

Permalink
reduced memory amount for network image
Browse files Browse the repository at this point in the history
reduced also the number of memory allocation for image storage
  • Loading branch information
Orbiter committed May 24, 2024
1 parent fe4c0aa commit 5f4ea9a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/net/yacy/visualization/RasterPlotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,9 @@ public static ByteBuffer exportImage(final BufferedImage image, final String tar

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();
Expand Down Expand Up @@ -1000,7 +1000,7 @@ public final byte[] pngEncode(final int compressionLevel) throws IOException {
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++) {
Expand Down

0 comments on commit 5f4ea9a

Please sign in to comment.