gpt4 book ai didi

Android Lucene OutOfMemoryExceptoin

转载 作者:行者123 更新时间:2023-11-29 00:36:25 24 4
gpt4 key购买 nike

我有一个 Lucene 索引,其中包含来自 1740 本书的 50571 个文档。我有两个创建此索引的进程。第一个过程是逐个文档在设备上创建索引。这个过程非常缓慢。另一个过程是在服务器上创建图书索引(与我在设备上创建它的方式完全相同),然后下载并将其与主索引合并。这个创建主索引要快得多。无论哪种方式,创建索引都可以正常工作。

问题是,当我在下载合并索引上搜索时,我得到一个 OutOfMemoryException,但是当我使用在设备上创建的索引进行搜索时,我没有得到那个错误。我逐本书(下载-合并)浏览并创建了索引书,并在每本书被索引后进行搜索;基于此,当我开始预订 ~450 时,我开始收到 OutOfMemoryException

是什么导致我内存不足。

最佳答案

Lucene 是一个内存消耗大户。当将“合并”索引写在一起时,它会将整个索引集存储在内存中两次。引用自 lucene documentation .

Note that this requires temporary free space in the Directory up to 2X the sum of all input indexes (including the starting index). If readers/searchers are open against the starting index, then temporary free space required will be higher by the size of the starting index

那是很大的内存。为了缓解这种情况,我们必须通过在索引编写器上调用 forceMerge(int) 来缩小索引的大小。这是一个缓慢的过程,但它确实缩小了索引的大小。每次索引目录中有 50 个或更多文件时,我都会用 1 参数调用它。

关于Android Lucene OutOfMemoryExceptoin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12429016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com