打开lucene索引时出错:映射失败

use*_*525 4 java lucene out-of-memory

我尝试使用1,2,3,4 GB的内存启动该过程但仍然得到相同的错误.有小费吗?gc日志显示它运行GC,即使它有足够的内存.但是这个错误可能与使用NIO的内存映射文件有关.以前有人见过这样的事吗?如果是这样,你是如何解决的?

$ java -d64 -server -Xmx15g -Xms15g -XX:+UseConcMarkSweepGC  -verbose:gc -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/frank/heap.dmp  -jar lukeall-3.5.0.jar 
    [Full GC 207648K->28758K(15660544K), 0.1105290 secs]
    [Full GC 61479K->15416K(15660544K), 0.0654310 secs]
    [Full GC 69950K->15418K(15660544K), 0.0717170 secs]
    [Full GC 69952K->15418K(15660544K), 0.0661720 secs]
    java.io.IOException: Map failed
        at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:849)
        at org.apache.lucene.store.MMapDirectory$MMapIndexInput.<init>(MMapDirectory.java:265)
        at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:216)
        at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:89)
        at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:115)
        at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:93)
        at org.apache.lucene.index.DirectoryReader.<init>(DirectoryReader.java:113)
        at org.apache.lucene.index.DirectoryReader$1.doBody(DirectoryReader.java:83)
        at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:754)
        at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:75)
        at org.apache.lucene.index.IndexReader.open(IndexReader.java:462)
        at org.apache.lucene.index.IndexReader.open(IndexReader.java:377)
        at org.getopt.luke.Luke.openIndex(Unknown Source)
        at org.getopt.luke.Luke.openOk(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at thinlet.Thinlet.invokeImpl(Unknown Source)
        at thinlet.Thinlet.invoke(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Component.java:4861)
    Caused by: java.lang.OutOfMemoryError: Map failed
        at sun.nio.ch.FileChannelImpl.map0(Native Method)
        at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:846)
        ... 48 more
Run Code Online (Sandbox Code Playgroud)

use*_*525 14

ulimit -v unlimited
Run Code Online (Sandbox Code Playgroud)

解决了这个问题!

  • +1它也适合我.自己注意:**1**`-v shell可用的最大虚拟内存量,在某些系统上可用于其子代.**2*`sun.nio.ch.FileChannelImpl.map`消耗内存_outside_ java虚拟机(因此更改`-Xmx`不能解决问题).该进程耗尽内存不是因为jvm无法创建对象,而是因为jvm没有更多来自系统的可用内存.**3**`限制仅在init`重新启动会话后生效 (3认同)