# java.lang.OutOfMemoryError:PermGen space

**URL:** https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336
**Category:** troubleshooting
**Created:** [March 19, 2021, 4:20am UTC](https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336 "2021-03-19T04:20:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mwill](https://community.openboxes.com/letter_avatar_proxy/v4/letter/m/b3f665/32.png) [@mwill](https://community.openboxes.com/u/mwill)
#### Post date: [March 19, 2021, 4:20am UTC](https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336/1 "2021-03-19T04:20:37Z")

</div>

Hello! I was getting “java.lang.OutOfMemoryError: PermGen space” errors after a few days of running the product. I had set up the setenv.sh file with the below. But after another week, again I see this error in the logs (the web UI gets super slow when this happens and then crashes). Can you please verify this is enough space, since it has happened twice now? I went ahead and added swap space today as well. Thanks!

**/opt/tomcat/bin# cat setenv.sh**

**export JAVA\_OPTS="-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m"**

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [March 19, 2021, 4:29am UTC](https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336/2 "2021-03-19T04:29:34Z")

</div>

Yeah this is one of the reasons I recommend 4GB of RAM. If you have 4GB, I think you could live comfortably with the following memory settings.

```auto
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms2048m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=256m"

```

Otherwise, at 2GB of total RAM I might recommend these settings (which might be tight and cause some issues with MySQL).

```auto
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=128m"

```

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [March 19, 2021, 4:30am UTC](https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336/3 "2021-03-19T04:30:08Z")

</div>

What OS version are you on?

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [March 19, 2021, 7:28pm UTC](https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336/4 "2021-03-19T19:28:32Z")

</div>

The reason I asked which OS you were on was because if you’re using Ubuntu, you can keep all of your configuration in the tomcat.service file.

[https://docs.openboxes.com/en/latest/installation/ubuntu1804/tomcat/#create-service](https://docs.openboxes.com/en/latest/installation/ubuntu1804/tomcat/#create-service)

---

<div class="post-metadata">

### Author: ![mwill](https://community.openboxes.com/letter_avatar_proxy/v4/letter/m/b3f665/32.png) [@mwill](https://community.openboxes.com/u/mwill)
#### Post date: [March 22, 2021, 6:35pm UTC](https://community.openboxes.com/t/java-lang-outofmemoryerror-permgen-space/336/5 "2021-03-22T18:35:30Z")

</div>

We are using an ec2 t3.medium Ubuntu instance. The documentation specifies “Environment='CATALINA\_OPTS=-Xms1024m -Xmx1024m -XX:MaxPermSize=128m” for the tomcat.service file. I will make the adjustments you specified in your comment. Thank you!
