====== Increase PHP Memory Limit for Java OutOfMemoryError ====== You have java installed on your server but are unable to load /directory/javatest.php It shows a memory related error when run the java command: java -version java.lang.OutOfMemoryError: unable to create new native thread OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14) instead of tomcat installed. Check error log: /tmp/jvm-81]cPs# cat hs_error.log # There is insufficient memory for the Java Runtime Environment to continue. # pthread_getattr_np # Possible reasons: # The system is out of physical RAM or swap space # In 32 bit mode, the process size limit was hit # Possible solutions: # Reduce memory load on the system # Increase physical memory or swap space # Check if swap backing store is full # Use 64 bit Java on a 64 bit OS # Decrease Java heap size (-Xmx/-Xms) # Decrease number of Java threads # Decrease Java thread stack sizes (-Xss) # Set larger code cache with -XX:ReservedCodeCacheSize= # This output file may be truncated or incomplete. # # Out of Memory Error (os_linux_x86.cpp:718), pid=553881, tid=139928360994560 # # JRE version: (7.0_79-b14) (build ) # Java VM: OpenJDK 64-Bit Server VM (24.79-b02 mixed mode linux-amd64 compressed oops) # Derivative: IcedTea 2.5.5 # Distribution: Built on CloudLinux Server release 6.6 (Leonid Kizim) (Thu Apr 16 03:44:02 EDT 2015) # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again PHP memory limit for lsphp5 external app could be the problem. You can add "system('ulimit -a') at the beginning of the test script to find out the limits for that process. Output phpinfo() is also a good idea to help identify the php memory_limit settting. The memory [[http://www.litespeedtech.com/docs/webserver/config/extapps#memSoftLimit|soft limit]] of lsphp5 external app may need to be increased. If it has been increased and "ulimit -a" from PHP script still shows a lower limit, you need to look into "memory_limit" set by php.ini or overridden by "php_value" in .htaccess. Finally increase memory limit to 4GB, and add java command parameter to limit java's memory usage, javatest.php works now. Actually 4GB is not enough for default java runtime. The java command result is normally sent to stderr and you can check /usr/local/apache/logs/stderr.log for the java version output.