java.lang.OutOfMemoryError: PermGen space
There are many reasons that you may get an OutOfMemoryError when you are running your application in Apache Tomcat server.
- Too many classes loaded in PermGen area.
- Memory leaks in your application.
- Trying to parse a huge file in memory.
- Using DOM XML parser to parse a huge XML file.
- Huge resultset received from Database.
You get this error when the PermGen memory area is full. The PermGen area is the part of the Java heap that is used to store information related to metadata like class declarations, methods and object arrays.
How to fix PermGen Error
Its also recommended to use profiling tools such as jconsole to see which classes are taking up space. If you think its due to the size allocated from PermGen using the JVM argument, then change them as follows in the Tomcat configuration file,
- Open Tomcat -> bin directory.
- Create a file named "setenv.bat" if on Windows or setenv.sh for macOS/Linux/Unix,
- Add the below lines in the file.
Windowsset "JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m -XX:MaxPermSize=512m -server"
macOS/Linux/Unixexport "JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m -XX:MaxPermSize=512m -server"
- Restart tomcat.
More Posts related to Tomcat,
- How to check installed Tomcat version
- How to kill tomcat server process using Mac Terminal Command
- Tomcat Manager Default Username and Password
- -bash: startup.sh: command not found - Apache Tomcat 8
- Error 404 Tomcat homepage http://localhost:8080/ not displayed
- Fix Apache Tomca: java.lang.OutOfMemoryError: PermGen spaceError
More Posts:
- How to install Packages in Sublime Text Editor - Sublime-Text
- How to add animated Gif to SharePoint Online Page - SharePoint
- Understanding AWS Calculator: DynamoDB on-demand capacity - AWS
- [Fix] Sharepoint: Embedding content from this website isnt allowed, but your admin can change this setting. - SharePoint
- Fix [oh-my-zsh] Cant update: not a git repository - Git
- How to save macOS Terminal outputs as text file - MacOS
- npm WARN saveError ENOENT: no such file or directory, open /mnt/c/package.json - JavaScript
- How to Read a binary File with Python - Python