Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.OutOfMemoryError: Java heap space #44

Open
Lychengit opened this issue Jun 27, 2023 · 4 comments
Open

java.lang.OutOfMemoryError: Java heap space #44

Lychengit opened this issue Jun 27, 2023 · 4 comments

Comments

@Lychengit
Copy link

Lychengit commented Jun 27, 2023

jvm:-Xmx600m

demo:

public static void main(String[] args) throws IOException {

    ImageInputStream iis = ImageIO.createImageInputStream(new File("D:\\fcs\\test\\test6\\test.jpeg"));

    Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
    if (!readers.hasNext())
    {
        throw new RuntimeException("No suitable ImageReader found for source data.");
    }

    ImageReader reader = readers.next();

    reader.setInput(iis, true, true);
    ImageReadParam irp = reader.getDefaultReadParam();
    irp.setSourceRegion(null);
    irp.setSourceSubsampling(2, 2,
            0, 0);

    BufferedImage image;
    try
    {
        image = reader.read(0, irp);
    }
    catch (Exception e)
    {
        // wrap and rethrow any exceptions
        throw new IOException("Could not read JPEG 2000 (JPX) image", e);
    }
    ImageIO.write(image, "jpeg", new File("D:\\fcs\\test\\test6\\1.jpeg"));
}

image file:
test.zip

@Lychengit
Copy link
Author

The source file is in the zip archive, please unzip it and test it

@Lychengit
Copy link
Author

I also can't control the overflow point using subsampling

@Lychengit
Copy link
Author

Is there any way to fix this overflow point

@Lychengit
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant