• Tomcat java.lang.OutOfMemoryError: PermGen space error


    Often time, Tomcat may hits the following java.lang.OutOfMemoryError: PermGen space error.

    java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    It’s usually happened after the Tomcat restarts a few times.

    1. Solution
    By default, Tomcat is assigned a very little PermGen memory for the running process. To fix it, increase the PermGen memory settings by using the following Java VM options.

    -XX:PermSize<size> - Set initial PermGen Size.
    -XX:MaxPermSize<size> - Set the maximum PermGen Size.
    In the next step, we will show you how to set the VM options in Tomcat, under Windows and Linux environment.



    2. Windows
    Tomcat is managed by this script file catalina.bat, dive inside the script, you will find out that catalina.bat always find and run the setenv.bat file to set the environment variables.

    {$tomcat-folder}incatalina.bat
    //...
    rem Get standard environment variables
    if not exist "%CATALINA_BASE%insetenv.bat" goto checkSetenvHome
    call "%CATALINA_BASE%insetenv.bat"
    goto setenvDone
    :checkSetenvHome
    if exist "%CATALINA_HOME%insetenv.bat" call "%CATALINA_HOME%insetenv.bat"
    :setenvDone
    //...
    2.1 To set the environment variable on Windows, create a setenv.bat manually, and put it into the ${tomcat-folder}in folder.

    ${tomcat-folder}insetenv.bat
    set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m
    P.S No double quotes, set JAVA_OPTS={value}.

    2.2 Restart Tomcat, it will call the setenv.bat file to set the environment variable automatically.

    {$tomcat-folder}incatalina.bat restart

  • 相关阅读:
    C# 之 判断或设置以管理员身份运行程序
    幻灯片母版 讲义母版 备注母版 区别 技巧
    ArcGIS中国工具2.5正式发布
    ArcGIS教程:曲率
    arcgis pro行列转换
    在 Python 中使用 in_memory 工作空间
    ArcGIS10.6的新功能
    ArcGIS Pro 获得工具的个数
    Android Push Notification实现信息推送使用
    SignalR推送服务在Android的实现 SignalA
  • 原文地址:https://www.cnblogs.com/Sir-Li/p/4178317.html
Copyright © 2020-2023  润新知