Skip to content

Instantly share code, notes, and snippets.

@boser87
Created September 3, 2015 07:59
Show Gist options
  • Save boser87/e360d6179dfe693dfe5b to your computer and use it in GitHub Desktop.
Save boser87/e360d6179dfe693dfe5b to your computer and use it in GitHub Desktop.
If you want to run AEM in debug mode and your Java heap space is not enough, AEM will try to fork a new process to get enough memory.
The debug options used to start the parent JVM are not passed on to the forked process by default.
By default, you would use the following command to run AEM in debug mode from console:
java -Xmx1520m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=30303,suspend=n -jar cq-author-4502.jar
If you don't have enough memory you will have this output in the console:
java -Xmx512m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=30303,suspend=n -jar aem-xxx.jar
Listening for transport dt_socket at address: 30303
Loading quickstart properties: default
Loading quickstart properties: instance
Low-memory action set to fork
Using 64bit VM settings, min.heap=1024MB, min permgen=256MB, default fork arguments=[-Xmx1024m, -XX:MaxPermSize=256m]
**** WARNING: insufficent heap memory ******************************************
The JVM reports 455 MB but we recommend at least 1024 MB +/- 20
Use your JVM's heap size option (like -Xmx1024M) to set that size.
Will fork a JVM to get enough memory.
********************************************************************************
**** WARNING: insufficent PermGen memory ***************************************
The JVM MBean:PS Perm Gen reports 82 MB but we recommend at least 256 MB +/- 20
Use your JVM's PermGen size option (like -XX:MaxPermSize=256M) to set that size.
Will fork a JVM to get enough memory.
********************************************************************************
Available memory below specified limits and low-memory action set to fork, will fork to get enough memory
Preparing to fork JVM, OS name=Windows 7, isWindows=true
Forking JVM: [C:\Java\jre7\bin\java.exe, -Xmx1024m, -XX:MaxPermSize=256m, -jar, -nofork, -pt, CHILD]
Loading quickstart properties: default
Loading quickstart properties: instance
Low-memory action set to fork
Using 64bit VM settings, min.heap=1024MB, min permgen=256MB, default fork arguments=[-Xmx1024m, -XX:MaxPermSize=256m]
**** WARNING: insufficent heap memory ******************************************
The JVM reports 910 MB but we recommend at least 1024 MB +/- 20
Use your JVM's heap size option (like -Xmx1024M) to set that size.
Will fork a JVM to get enough memory.
********************************************************************************
The JVM MBean:PS Perm Gen reports a maximum size of 256 MB, meets our expectation of 256 MB +/- 20
Available memory below specified limits and low-memory action set to fork, will fork to get enough memory
Not forking JVM as -nofork option is set
Setting properties from filename '...'
Verbose option not active, closing stdin and redirecting stdout and stderr
Redirecting stdout to \crx-quickstart\logs\stdout.log
Redirecting stderr to \crx-quickstart\logs\stderr.log
Press CTRL-C to shutdown the Quickstart server...
As you can read from the above output, the main process we have started does not have enough memory, so a new process is forked. The new process is forked with default arguments: -Xmx1024m, -XX:MaxPermSize=256m, -jar, -nofork, -pt, CHILD.
This means that the new process was not forked with the parameters for the debug mode.
We use a specific command to pass the debug mode parameters to the forked process:
java -jar cq5-author-4502.jar -fork -forkargs -- -Xdebug -Xrunjdwp:transport=dt_socket,address=30303,suspend=n,server=y -Xmx1520m -XX:MaxPermSize=512m -XX:-UseSplitVerifier
Now the output will be something like this:
Forking JVM: [C:\Java\jre7\bin\java.exe, -Xdebug, -Xrunjdwp:transport=dt_socket,address=30303,suspend=n,server=y, -Xmx1520m, -XX:MaxPermSize=512m, -XX:-UseSplitVerifier, -jar, -nofork, -pt, CHILD, -fork, -forkargs, --, -Xdebug, -Xrunjdwp:transport=dt_socket,address=30303,suspend=n,server=y, -Xmx1520m, -XX:MaxPermSize=512m, -XX:-UseSplitVerifier]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment