0

I am trying to execute this program using fork and join framework. When I feed a JPEG image of smaller size to this program it works fine, but when I give the image of size more than 4 MB it throws below exception:

****Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at ForkBlur.blur(ForkBlur.java:120)
    at ForkBlur.main(ForkBlur.java:110)****

I am using eclipse Helios IDE.

I want it to work for larger images of size more than 50 MB

9
  • 3
    It clears says what the error is.So what do you want actually? Commented Jan 17, 2013 at 17:56
  • 2
    What matters is the size of the image uncompressed. This can be up to 100x larger. I suggest increasing the maximum memory you give the running program. Commented Jan 17, 2013 at 17:57
  • 1
    You need to set the Java runtime parameters to specify a larger heap size in the Run options for your project Commented Jan 17, 2013 at 17:58
  • 1
    Try adding -Xmx1g to the VM/command line options for your running program. Commented Jan 17, 2013 at 18:03
  • 2
    stackoverflow.com/questions/8600972/… Commented Jan 17, 2013 at 18:03

3 Answers 3

7

It worked fine for me .

Right click on project which you want to run . Run As -> Run configuration ->Arguments .

Then in VM arguments:

-Xmx1g

Sign up to request clarification or add additional context in comments.

Comments

2

You'll need to tell the JVM to allow for more memory for your program. If running the program from the command line, you would use the -mx option to specify how much memory the JVM is allowed to use.

For example, to allow for 128MB of memory, you would do:

java -mx128M MyClass

If running from Eclipse Helios, do this:

  1. Right click on the project and go to properties.
  2. Click on Run/Debug Settings.
  3. Choose your run configuration and click Edit or click New to create one using the Java Application configuration type.
  4. On the Arguments tab, put -mx128M in the VM arguments box.

2 Comments

AFAIK, it is Xmx, the command line option, mx is probably a typo?
@Scorpion - The mx option is now a standard java option and doesn't require the leading X anymore. Although -Xmx will still work, and may be required if you are using an older version of Java.
2

You need to specify a bigger heap size when you run the program.

You can do it via eclipse if that's your preferred tool. You can right click on the file containing the main method, choose the option "Run As" - this would open up a dialog where you can set up host of command line options (look for arguments section).

The command line option to configure the maximum heap size is Xmx; an example would be Xmx 2g to set the maximum heap size to 2 gb.

3 Comments

It would be nice to include how, for those who don't know.
Can you tell me the steps to do that ?
I am just completing the answer, it takes me a few seconds to complete the answer. I know it takes lesser time to down vote but still would request to control the urge :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.