1

我正在索引约 250.000 个文档,但在 200.000 左右后达到 OOME(在此之前,它变得非常慢,直到达到 GC 限制)。

代码如下所示(我使用的是 jpype):

def index_documents(self, documents):
    writer = IndexWriter(self.store, self.config)
    for document in documents:
        self.indexDocument(document,writer)

    writer.commit()
    writer.close()

def indexDocument(self, document, writer):
    doc = Document()
    doc.add(Field('text',document['text'],TextField.TYPE_STORED))
    doc.add(Field('title',document['title'],TextField.TYPE_STORED))
    doc.add(Field('url',document['url'],StringField.TYPE_STORED))
    doc.add(Field('domain',document['domain'],StringField.TYPE_STORED))
    doc.add(Field('category',document['category'],StringField.TYPE_STORED))

    writer.addDocument(doc)

我希望文档和字段会被刷新,然后每隔一段时间进行一次垃圾收集,所以应该不可能命中 OOME。相反,似乎某处有泄漏。如何确定这是否是 lucene 或 jpype 的问题?假设这是一个 lucene 问题,我有什么可能减少内存使用?我可以诊断冲洗发生的频率或类似情况吗?

4

1 回答 1

0

正如 bastian 评论的那样,更新 JPype 解决了这个问题。该修复程序实际上已在 0.6.0 版中发布。

此外,我在第三方组件中存在内存泄漏,如果没有 Jpype 错误,我可能不会发现 ;-)

于 2015-04-13T08:31:12.967 回答