Lucene索引将Gen0存储器转换为不受管理的资源
我正在使用 Lucene NET v4.8 beta,我注意到每当我向索引添加大量数据时,我的服务会消耗越来越多的内存。
我通过 dotMemory 对此进行了分析,如下所示。第 4 分钟内存峰值是当我向索引添加一堆数据时。我了解 gen0 内存的增加是因为我正在创建 IndexWriter 对象并执行写入/提交操作。然而,似乎一旦调用 GC,它收集的 gen0 对象就会变成非托管内存的一部分(例如,屏幕截图中的 5:30 分钟) ,我们可以看到 gen0
内存使用量已收集,但总内存
保持不变 - 非托管内存
增长的量与 gen0 相同
内存已被收集)。
我已经在我的代码中为 IndexWriter
和 < code>IndexReader,但这个问题仍然存在。我能做的唯一“修复”是通过代码中的 GC.Collect() 手动强制垃圾收集器进行收集,但它仍然无法删除所有额外的内容非托管内存。
我的问题是,是什么导致 Lucene NET 表现得像这样(将 gen0 对象变成非托管资源)?有没有办法解决这个问题,而不必经常执行 GC.Collect() ?
I am using Lucene NET v4.8 beta, and I have noticed that my service consume more and more memory whenever I add huge amounts of data to the index.
I analyzed this through dotMemory, seen below. The spike of memory at minute 4 is when I added a bunch of data to the Index. I understand the increase in gen0 memory because I am creating IndexWriter
object and performing write/commit operations. However, it seems as if, once the GC is called, the gen0
objects it collects becomes part of unmanaged memory
instead (for example, at minute 5:30 in the screenshot, we can see that gen0
memory usage got collected, but total memory
remained the same - unmanaged memory
grew the same amount that gen0
memory got collected).
I have already implemented the Dispose pattern in my code properly for IndexWriter
and IndexReader
, but this issue remains. The only 'fix' I was able to do I was able to do was forcing Garbage Collect to collect, via GC.Collect()
manually in the code, but it still doesn't remove all the extra unmanaged memory.
My questions are, what is causing Lucene NET to behave like this (turning gen0 objects into unmanaged resources)? And is there a way to fix this without having to do GC.Collect()
every so often?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论