• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutofMemory while reading JPEG file Using IMAGEIO

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hello All

I am reading an Jpeg file using following snippets



the file i try to read is 6480 and 4320 in dimension and just 2.34 MB in size. my heap size is 1024 MB.and i want to read file even larger in size say 25 - 30 mb and 10,000 * 12,000 in dimensions. then what all experts suggest me to accomplish my goal

getting following exception


 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPEG compresses images well. But in memory, a BufferedImage generally needs 4 bytes for each pixel just for the raw data, so that would be 6480 * 4320 * 4 = 112 MB, regardless of how big the file is.

With a 1024MB heap, that should still fit, though, unless there's tons of other stuff that can't be GC-ed. What's the command you use to start the JVM? Post all the options.

Have you tried allocating 2GB instead of 1GB?
 
Mihir K Parekh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

thank you for your reply.i am using eclipse latest version. and i do understand your point of BufferedImage uncompressed size calculation. is there any other way to load big jpeg images into my application ? like BigDecimal in java is there any other option for large image file ?

Thank You
Mihir Parekh
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try running your code outside of the IDE; who knows what that does to the memory settings. And then post here the command line arguments you used to start the JVM.
 
Mihir K Parekh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

when i run my code out of ide it works fine.

my myeclipse.ini is

-startup
../Common/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
../Common/plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-install
C:/Program Files/Genuitec/MyEclipse-8.6
-vm
C:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client/jvm.dll
-configuration
configuration
-vmargs
-Xmx1024m
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=128m


so why can i run same code with no error outside of IDE ?

Thank You
Mihir Parekh
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because of this:

Ulf Dittmer wrote:... who knows what that does to the memory settings.


IDEs are memory hogs; Eclipse probably needs 256MB or more just for itself.

For running the code in Eclipse; dig into the Eclipse settings to find out where you can set the JVM parameters for child processes - giving those 1 GB is unlikely to be the default, so as long as you don't change those values you'll run into trouble.
 
reply
    Bookmark Topic Watch Topic
  • New Topic