- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 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/
我有一个 Lucene 索引,其中包含来自 1740 本书的 50571 个文档。我有两个创建此索引的进程。第一个过程是逐个文档在设备上创建索引。这个过程非常缓慢。另一个过程是在服务器上创建图书索引(
我是一名优秀的程序员,十分优秀!