牛骨文教育服务平台(让学习变的简单)
博文笔记

hadoop学习笔记(五) java heap space报错

创建时间:2013-05-04 投稿人: 浏览次数:177

                  Java    heap   space 报错

实验过程中,执行map过程中,出现task failed,报错为java heap space,原因是jvm的内存太小了,无法达到要求,修改方法一般是改进程序,减小程序消耗的内存,还有就是增大datanodejvm内存。

因为在datanode上使用java -Xmx命令出现无法创建虚拟机的报错(不知道什么原因),所以只能去更改mapred里面的默认设置。

我们可以去mapred-default中看看,发现jvm内存的最大值为200M,现在不够我们将它修改为512m

<property>

  <name>mapred.child.java.opts</name>

  <value>-Xmx200m</value>

  <description>Java opts for the task tracker child processes.  

  The following symbol, if present, will be interpolated: @taskid@ is replaced 

  by current TaskID. Any other occurrences of "@" will go unchanged.

  For example, to enable verbose gc logging to a file named for the taskid in

  /tmp and to set the heap maximum to be a gigabyte, pass a "value" of:

        -Xmx1024m -verbose:gc -Xloggc:/tmp/@taskid@.gc

  

  The configuration variable mapred.child.ulimit can be used to control the

  maximum virtual memory of the child processes. 

  </description>

</property>

然后在mapred-site.xml里面加上

<property>

  <name>mapred.child.java.opts</name>

  <value>-Xmx512m</value>

  <description>Java opts for the task tracker child processes.  

  The following symbol, if present, will be interpolated: @taskid@ is replaced 

  by current TaskID. Any other occurrences of "@" will go unchanged.

  For example, to enable verbose gc logging to a file named for the taskid in

  /tmp and to set the heap maximum to be a gigabyte, pass a "value" of:

        -Xmx1024m -verbose:gc -Xloggc:/tmp/@taskid@.gc

  

  The configuration variable mapred.child.ulimit can be used to control the

  maximum virtual memory of the child processes. 

  </description>

</property>

即可。

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。