23

how to increase ant permgen size? I have given in ANT_OPTS as

-Xms768m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=128m

question 1)After specifying above setting in system environment, still i am getting outof memeory error for ant target for junit.

Caught an exception while logging the end of the build.  Exception was:
java.lang.OutOfMemoryError: PermGen space

2) when i type in command promt to see what is path for ant_opts, echo %ant_opts% it shows only

-Xmx512m

and other parts skips. is something wrong in my path? Note: i am using command prompt to run ant target.

TechFind
  • 3,696
  • 18
  • 47
  • 62
  • Check that you don't have any other variable (like `JAVA_OPTS`) overriding it. – Michael Jun 17 '11 at 14:34
  • Are you running this through some sort of container? Perhaps it isn't passing the values on. – Mike Miller Jun 17 '11 at 14:35
  • no i dont have any other OPTS. I am running integration test which takes longer time to execute test cases.using command prompt to run ant target for junit report. – TechFind Jun 17 '11 at 14:36

3 Answers3

25

go to my computer->right click->properties->Advanced->environment variables->New(in system/user variable)->

enter

Varible name: ANT_OPTS
Varible Value : -Xms1536m -Xmx1536m -XX:PermSize=1024m -XX:MaxPermSize=2048m

Note:

  1. configure values according to your system memory size.

  2. This config for windows, for other OS config accordingly

For MAC:

in Terminal, goto pom.xml path in project, run below command:

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m" Note: Size is based on system RAM. I used maven instead of old Ant. use MAVEN_OPTS/ANT_OPTS for maven/ant config.

AKB
  • 5,918
  • 10
  • 53
  • 90
3

What does your test do? Does it call a recursive method?

Also, the values that you enter for your test will override any system setting. Try this in your call to junit in your Ant script:

<junit fork="yes" maxmemory="1024">
bakoyaro
  • 2,550
  • 3
  • 36
  • 63
  • 1
    Whats the default if you don't supply `maxmemory`? – Blundell Jun 15 '12 at 09:24
  • Great answer! I found that I was getting an out of memory error because our `` had been changed. By default, it's `perTest`, but if it's changed to something else (e.g. `once`) then this can cause OutOfMemory exceptions since junit doesn't start a new VM instance for each test. – Brad Parks Apr 21 '14 at 15:52
1

for my junit ant target I just set fork="true" that way a new jvm would be initiated for the junit tasks, there's also forkmode="perBatch"or "perTest", worked for me!

jp093121
  • 1,752
  • 19
  • 13