我有一个 Java 8 应用程序,它通过网络接收消息并使用 Java NIO MappedByteBuffer 写入多个内存映射文件。我有一个阅读器,它可以按顺序从这些文件中同时读取消息,并使用 MappedByteBuffer 再次删除读取的文件。一切都很顺利,直到我写入和读取了大约 246 GB 的数据并且我的应用程序因以下原因而崩溃
[thread 139611281577728 also had an error][thread 139611278419712 also had an error][thread 139611282630400 also had an error][thread 139611277367040 also had an error][thread 139611283683072 also had an error][thread 139611279472384 also had an error]
[thread 139611280525056 also had an error]
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGBUS (0x7) at pc=0x00007f02d10526de, pid=44460, tid=0x00007ef9c9088700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode linux-amd64 )
# Problematic frame:
# v ~StubRoutines::jint_disjoint_arraycopy
#
# Core dump written. Default location: /home/user/core or core.44460
#
# An error report file with more information is saved as:
# /home/user/hs_err_pid44460.log
这hs_err_pid44460.log
是空的,核心转储core.44460
的大小约为 246 GB,并且充满了我正在尝试编写的消息。
我运行的最大堆大小为 32 GB。根据 JConsole,我用完了Free Physical Memory
然后崩溃。
为什么我的 RAM 用完了?我是否忘记关闭某些文件句柄/没有正确关闭我的 MMapped 文件?