java - tomcat启动的时候,报这个错,在bin目录下的hs_err_pid7752.log
伊谢尔伦
伊谢尔伦 2017-04-18 10:27:25
[Java讨论组]
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1048576 bytes for AllocateHeap
# 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 (memory/allocation.inline.hpp:61), pid=7752, tid=4676
#
# JRE version:  (7.0_79-b15) (build )
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Call to MiniDumpWriteDump() failed
#

---------------  T H R E A D  ---------------

Current thread (0x0000000002501000):  JavaThread "Unknown thread" [_thread_in_vm, id=4676, stack(0x0000000002920000,0x0000000002a20000)]

Stack: [0x0000000002920000,0x0000000002a20000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(3)
伊谢尔伦

看提示是说分配 1048576 字节的 Native 内存 时失败了. native 内存不足, 不代表 JVM 的堆内存不足, 因为 native 内存是由 C 语言中的 malloc 所分配的, 它不包含在堆内存中. 出现 native 分配失败的情况, 一般就是因为整个操作系统的物理内存不足了, 导致没有多余的内存空间分配给 native 内存.

而上面的错误提示也给出了解决方法:

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)

其中提到了三点关键的:

  1. 减少堆内存(-Xmx/-Xms);

  2. 减少 Java 线程数.

  3. 减少 Java 的线程堆栈大小(-Xss).

为什么这样做呢? 因为 native 内存不在 Heap 中, 因此 JVM 所占用的实际内存由: native 内存 + Heap 内存 + 栈内存 + 其他, 因此减少 Heap 内存, 那么可用的 native 内存就提高了.

大家讲道理

1048576 bytes 这是 1Mb 吧。只给堆分配这么点内存吗?

高洛峰

看样子是内存不足导致的

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号