• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4750
  • Last Modified:

Increasing Heap size in Java

How can I increase the heap memory of a JVM Permanently.

I want to run an executable jar file, for which 64MB heap is not enough(Preferable 512).

Is it possible to do it in the program??
I am using Apache ANT for building the program. Is it possible to specify in build.xml??

Please help me in this regard

Thanks & regards
0
sree032397
Asked:
sree032397
1 Solution
 
MilanKMCommented:
0
 
sree032397Author Commented:
But this is useful for temporary purpose only. I want it to be permanent
0
 
InteractiveMindCommented:
> Is it possible to do it in the program??

No.

Available JVM memory must be specified on execution of the JVM; the JVM is executed prior to loading and running any application, so the only way to do this is really with parameters to java.exe/javaw.exe/..

A lot of Java applications are initialized either using an EXE, or a simple BAT script — as these can specify mem size to the JVM during initialization.


I agree that it's a pain.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sree032397Author Commented:
Thank you,
Is it possible to specify the heap size in Build.xml while using ANT
0
 
d_g_watsonCommented:
Yes, if you're using the ant task "java" to run your jar file, you can set the heap size within the task, like this:

        <java jar="test.jar"
           fork="true"
           failonerror="true"
           maxmemory="512m"
           >
         <arg value="-h"/>
         <classpath>
           <pathelement location="test.jar"/>
           <pathelement path="${java.class.path}"/>
         </classpath>
       </java>

Alternatively, you can set the JVM args like this:

  <java .....>
    <jvmarg value="–Xms512m –Xmx512m"/>
  </java>


Hope that helps,
Dave.
0
 
sree032397Author Commented:
Thank you,

That works fine,
Is it possible to specify it while running aw executable jar file(Double lick).
or is it possible to hide the command prompty while running a bat file??

0
 
d_g_watsonCommented:
> Is it possible to specify it while running aw executable jar file

Does the first ant example, above, not do this?

> is it possible to hide the command prompty while running a bat file

In your batch file, use the "javaw" command, rather than "java". "javaw" is the same as "java", except there's no associated console.

Dave.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now