Results 1 to 3 of 3
  1. #1
    pir8ped is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default Displaying large images


    A typical image I want to display ( and be able to scroll around ) is 20 Mb, 10000 x 5000 pixels, png format.

    Trying to load such an image, I get Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

    despite increasing the heap space available to the runtime environment with:


    in the eclpise.ini file

    I have tried loading just a portion of the image and this works:

    File file = new File(ChartInfo.chartDir + "\\"
    + currentChart.getFileName());
    ImageInputStream iis = ImageIO.createImageInputStream(file);
    Iterator readers = ImageIO.getImageReadersByFormatName("png");
    reader = (ImageReader);
    reader.setInput(iis, true);

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    viewRectangle = new Rectangle(dim);

    ImageReadParam readParam = reader.getDefaultReadParam();

    However, the image takes 5 seconds to load. Scrolling to a different part of the image takes just as long.

    Any suggestions most welcome.



  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    I don't use Eclipse, but doesn't changing runtime parameters in the ini file only affect Eclipse itself and not the application run from Eclipse?

    In NetBeans, the parameters with which an application is run are set from the project properties. I imagine Eclipse would have something similar.


  3. #3
    pir8ped is offline Member
    Join Date
    Jan 2009
    Rep Power


    You're right Darryl, thanks.

    In Eclipse:
    Run As -> Open Run Dialog ->
    -> (x)=Arguments -> VM Arguments

    Setting a bigger value there fixed the problem.

Similar Threads

  1. displaying uploaded images on the browser
    By newton in forum Web Frameworks
    Replies: 3
    Last Post: 03-31-2011, 10:56 AM
  2. Code too large for try statement
    By vravindran in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 01-09-2009, 11:49 AM
  3. Compare 2 large files
    By bezudar in forum Advanced Java
    Replies: 3
    Last Post: 11-23-2008, 02:18 AM
  4. [SOLVED] Need help in displaying images
    By kirly in forum Advanced Java
    Replies: 3
    Last Post: 10-21-2008, 05:36 AM
  5. Images not displaying in JSP in IE7
    By chadscc in forum Advanced Java
    Replies: 0
    Last Post: 11-13-2007, 03:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts