lucene.net 64bit OutOfMemoryException

本文关键字:OutOfMemoryException 64bit net lucene | 更新日期: 2023-09-27 18:17:12

我有一个Lucene索引,是313MB通过ASP运行。64位下的。NET网站。当我启动应用程序,并在CreateLuceneIndex()方法中使用IndexReader.Open(directory, true)读取索引时,我看到IIS Express Worker进程膨胀到超过4GB,然后bang - OutOfMemoryException!

谁能解释为什么和我需要做什么来解决这个问题?当实际索引大小只有313MB时,为什么会发生这种情况?

注意:容器是一个DI容器(Funq)

private void CreateLuceneIndex(Container container)
{
    var directory = CreateDirectory();
    var indexWriter = CreateIndexWriter(container, directory);
    //indexWriter.DeleteAll();
    //var fieldDictionary = CreateIndexFieldDictionary();
    //PopulateLuceneIndex(indexWriter, fieldDictionary);
    indexWriter.Dispose();
    container.Register(new IndexSearcher(IndexReader.Open(directory, true)));
}
private Directory CreateDirectory()
{
    var useAzureBlob = _appSettings.Get("UseAzureBLOBStorage", false);
    var blobStorageEndpoint = _appSettings.Get("blobStorage", string.Empty);
    var directory = useAzureBlob
        ? (Directory)
            new AzureDirectory(CloudStorageAccount.Parse(blobStorageEndpoint), "Catalogue")
            : new MMapDirectory(new DirectoryInfo(Environment.CurrentDirectory));
    return directory;
}
private IndexWriter CreateIndexWriter(Container container, Directory directory)
{
    container.Register<Analyzer>(new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
    var analyser = container.TryResolve<Analyzer>();
    var indexWriter = new IndexWriter(directory, analyser, IndexWriter.MaxFieldLength.UNLIMITED);
    indexWriter.SetRAMBufferSizeMB(10.0);
    return indexWriter;
}

lucene.net 64bit OutOfMemoryException

我还没有弄清楚为什么,但我发现从MMapDirectoryFSDirectory的变化为我解决了这个问题。

相关文章:
  • 没有找到相关文章