内存不足java堆异常

时间:2013-03-04 13:55:42

标签: shell

我在unix环境中运行我的java代码时出现了内存java堆异常。

我有bash shell脚本,在运行脚本后我会在几个seconsd中调用java类来获取错误。

任何建议都会有所帮助。

以下是我的shell脚本。

home_dir=/opt/IBM/IEEP/MigrationBatch
java_home=/opt/IBM/WAS/java
lib_path=$home_dir/lib
job_path=$home_dir/bin/jobs
config_path=$home_dir/bin/config

batch_root_path=$home_dir
root_path=$batch_root_path/migration

mkdir -p $root_path
mkdir -p $root_path/working

log_date=$(date +%m%d%Y_%H%M%S)
run_date=$(date +%Y%m%d_%H%M%S)
job_name="MigrationBatch"

script_log_path=$root_path/script_logs
logfile=$script_log_path/script_log_migration_txt_$log_date.txt
mkdir -p $script_log_path
echo "Script Log Files available at $logfile"
exec>>$logfile
echo "Starting Java process for MigrationBatch Job...."

## STEP 1 : Run the Java Job
export JAR_HOME=$lib_path
export JOB_HOME=$job_path
export CONFIG_HOME=$config_path

JAR_CLASSPATH=:$lib_path/activation-1.1.jar:
echo $JAR_CLASSPATH

$java_home/bin/java -Djob_name=$job_name - Drun_timestamp=$run_date -cp $JAR_CLASSPATH:$job_path:$config_path org.springframework.batch.core.launch.support.CommandLineJobRunner migrationJob.xml  migrationJob -next

script_output="$(echo $?)"

1 个答案:

答案 0 :(得分:2)

这不是你的shell内存不足,这是你可以尝试的java命令行执行:

 java -Xmx1024m -jar jarfie
 java -Xms512m -Xmx2g -jar somejar
 $java_home/bin/java -Xms512m -Xmx2g -Djob_name=$job_name -Drun_timestamp=$run_date -cp $JAR_CLASSPATH:$job_path:$config_path org.springframework.batch.core.launch.support.CommandLineJobRunner migrationJob.xml migrationJob -next

如果仍然存在内存问题,则可能需要增加更多