douche1936 2016-06-02 09:41
浏览 63
已采纳

php(web服务器)调用java无法正常工作

Problem

  • When call the java in php (web server), Out of Memory Error occurs.

State

  • web server - centos 6 , nginx, php-fpm , java
  • call the java in centos - success
  • call the java in php - Out of Memory Error occurs

Call API

  • Case : php
$string = exec('java -Xms2g -Xmx2g -jar /usr/share/nginx/html/my_test.jar /mytmp/testfile’, $output, $code);
  • Case : centos 6 (linux)
java -Xms2g -Xmx2g -jar /usr/share/nginx/html/my_test.jar /mytmp/testfile

Error Message

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2555904 bytes for committing reserved memory.
# 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.cpp:2673), pid=2549, tid=140226036020992
#
# JRE version:  (8.0_45-b14) (build )
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

Question

  • why different work ?
  • how to solved that ?

I try that (not solve)

  • set memory
java -Xms2g -Xmx2g 
  • 写回答

1条回答 默认 最新

  • doubi2145 2016-06-03 05:05
    关注

    i solve thaht.
    "setsebool -P httpd_execmem on"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?