Search code examples
javamemoryout-of-memorypermgenapache-karaf

Apache Karaf startup script. How to set more perm memory?


I am trying to figure out how to increase karaf's permgen memory. In the karaf's start up script I see that there is:

if not "%JAVA_PERM_MEM%" == "" (
    set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:PermSize=%JAVA_PERM_MEM%
)
if not "%JAVA_MAX_PERM_MEM%" == "" (
    set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:MaxPermSize=%JAVA_MAX_PERM_MEM%
)

I understand that the JAVA_PERM_MEM and JAVA_MAX_PERM_MEM is the variables but they are not defined anywhere in startup script except here.

The karaf is running on live machine so I do not want to make any experiments on it I need to be sure if doing like this:

if not "%JAVA_PERM_MEM%" == "" (
    set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:PermSize=512M
)
if not "%JAVA_MAX_PERM_MEM%" == "" (
    set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:MaxPermSize=1024M
)

will increase the permgen memory? The reason I need to do it is because I keep getting the: Caused by: java.lang.OutOfMemoryError: PermGen space

EDIT:

All the bundles deployed on karaf are spring related, they have camel routes, cxf endpoints, OpenJPA persistence configuration all is manage via Spring. But I do not think that there is the problem, because as I know OutOfMemory PermGen space means there is not enough memory for all deployed applications. If someone know where might be the issue it would be very helpful.


Solution

  • These variables are probably going to be read from your environment, so just define them.

    export JAVA_PERM_MEM...
    

    About the PermGen exception, do you may be use spring DM? or some spring related osgi bundles? There are a couple of issues around that.