Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Memory use in Java

43 sec read

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.

Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

One Reply to “Memory use in Java”

Leave a Reply

Your email address will not be published. Required fields are marked *