简体   繁体   English

Linux:无法启动:内存不足

[英]Linux :Can't start up: not enough memory

I wrote a small java application and also wrote a small linux script to execute this Java program under Linux server . 我编写了一个小型Java应用程序,还编写了一个小型Linux脚本来在Linux服务器下执行此Java程序。

But when ever i am trying to run this linux script , i am getting this Error 但是,每当我尝试运行此linux脚本时,都会收到此错误

Can't start up: not enough memory 无法启动:内存不足

Could anybody please help me in how to resolve this ?? 有人可以帮助我解决这个问题吗?

This is my Script 这是我的剧本

echo "Start time: " `date`

SERVER_HOME=$HOME/

export CLASSPATH=.:

export CLASSPATH=$CLASSPATH$SERVER_HOME/home/kiran/apiToplist/lib/*:

echo $CLASSPATH


java -cp $CLASSPATH -Xmx2G com.tata.samples.QuoteData
echo "End time: " `date`

Do you really need 2GB of memory for a small java application? 小型 Java应用程序真的需要2GB的内存吗? The value -Xmx2G tells the jmv to reserve 2GB of memory for your application. 值-Xmx2G告诉jmv为您的应用程序保留2GB的内存。 If this is not available it will not work. 如果不可用,它将无法正常工作。

If 2GB is not needed, consider removing the value or lowering it. 如果不需要2GB,请考虑删除该值或降低它。

For Red Hat based systems, check to see if you are using GNU libgjc: 对于基于Red Hat的系统,请检查您是否正在使用GNU libgjc:

java -version

java version "1.5.0"
gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-3)

Installing OpenJDK fixed the issue for me: 安装OpenJDK为我解决了这个问题:

yum install java-1.7.0-openjdk-devel

Read more about Installing OpenJDK on Red Hat Enterprise Linux 阅读有关在Red Hat Enterprise Linux上安装OpenJDK的更多信息。

Confirm that java has been updated: 确认Java已更新:

java -version

java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

Start your java application. 启动您的Java应用程序。

A 2G heap allocation is very large, and on some 32bit JVMs its larger than is permitted. 2G堆分配非常大,在某些32位JVM上,它的大小超出了允许的范围。

Try reducing the heap allocation to something smaller (using -Xmx ), or use a 64bit JVM (which can have much larger heaps). 尝试将堆分配减小到较小的值(使用-Xmx ),或使用64位JVM(可以具有更大的堆)。

If it's not a resource problem, try and reduce the value for Xmx flag. 如果这不是资源问题,请尝试减小Xmx标志的值。 Have a look here . 在这里看看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM