When you run a Java application, there is usually a fixed maximum amount of memory which is available. This is usually 64 megabytes of memory.
So if you run a java program from the command line like this, the program can use a maximum of 64 megabytes of memory (this is the default).
java -jar jpedal.jar
Sometimes, you need more memory. So there is a useful Java option (-Xmx) to increase the maximum memory available. The format is slightly fiddly so best shown with an example which tells Java to use a maximum memory of 128 megabytes instead
java -Xmx128M -jar jpedal.jar
The number value comes straight after the -Xmx flag and then the M tells Java the figure means megabytes (which is the most common setting you would use). The memory needs to be available – if it is not the program will fail to run.
So if you need a little more memory, just add this flag to your Java command.
I was asked to explain memory usage in a (hopefully) non-technical way which led to this short article. If there is anything Java/PDF related which you would explained, please drop us a line and we will try to help.
Do you need to solve any of these problems in Java?
Convert PDF to HTML5 | Convert PDF to SVG | View Forms in the browser |
View PDF Documents | Convert PDF to image | Extract Text from PDF |
Read/Write images | Replace ImageIO | Convert Image to PDF |
This will complement my copy of “Take Control of the Mac Command Line with Terminal (1.0.2)” nicely.