Linux – JVM outputs “No console, will fork to get enough memory” when started via cron

javalinux

I have come across an odd message when starting up a JVM via cron: "No console, will fork to get enough memory". Google only returns a handful of results when searching for that string, so I figured I'd ask here to see if anyone knows more about it…

This message does not come up when I start the JVM from command line or when the JVM is started at boot time via init script.

In all cases, the same init script is called to start it, and the JVM is being passed the same arguments:

java -server -Xmx4096m -XX:MaxPermSize=256M -Djava.awt.headless=true -Djava.security.auth.login.config=/usr/local/aem/
author-4502/crx-quickstart/conf/ldap_login.conf -Dcom.sun.management.jmxremote.port=9502 -Dcom.sun.management.jmxremote.
authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar cq5-author-p4502.jar -use-control-port -p 4502 -gui -no
browser -verbose -r japan,qa

More specifically, the JVM message is output in this context:

...
Low-memory action set to fork
Using 64bit VM settings, min.heap=1024MB, min permgen=256MB, default fork arguments=[-Xmx1024m, -XX:MaxPermSize=256m]
The JVM reports a heap size of 3641 MB, meets our expectation of 1024 MB +/- 20
The JVM MBean:PS Perm Gen reports a maximum size of 256 MB, meets our expectation of 256 MB +/- 20
No console, will fork to get enough memory
...

It seems that there is some default behavior where the JVM will fork another instance to get around low memory situations. So I'm wondering why would invoking the JVM from a cron job trigger this behaviour? Why would not having a console be interpreted as 'low memory' even if the JVM has already confirmed it has enough heap and permgen memory?

I'm using RHEL 6.4.

Java package name: jdk-1.7.0_55-fcs.x86_64

java -version output:

java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

Best Answer

That message is coming from the CQ application, not the JVM. From what I gather, in some circumstances CQ will launch separate JVMs for different parts of the system. CQ has some command-line options to control this behavior:

-debug <port>
         Enable Java Debugging on port number; forces forking                   
-nofork
         Do not fork the JVM, even if not running on a console                  
-fork
         Force forking the JVM if running on a console, using recommended       
         default memory settings for the forked JVM.                            
-forkargs <args> [<args> ...]
         Additional arguments for the forked JVM, defaults to '-Xmx1024m        
         -XX:MaxPermSize=256m '.  Use -- to specify values starting with -,     
         example: '-forkargs -- -server'

See this page for details on starting and stopping CQ. Search for "fork" to see the (few) mentions they make of this behavior.