Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to resolve java memory heap space error when reading image from its input stream??

Mani kantaAug 1 2017 — edited Aug 3 2017

Hi All,

I am using J developer Studio Edition Version 11.1.1.7.0.

I implemented solution for compressing jpeg and png type images. where I can able to compress the images with less size successfully. But, for large images more than 2MB, I am getting java heap space error when I read image from its input stream as below.

                InputStream inputStream = file.getInputStream());

                BufferedImage image = ImageIO.read(inputStream);            --------> Getting java.lang.OutOfMemoryError: java heap space

May I know why this happens and how to resolve without increasing heap memory.

Regards,

Mani

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2017
Added on Aug 1 2017
13 comments
726 views