Lucene 创建重复索引
我使用 lucene 创建了一个应用程序。服务器最终抛出内存不足错误,因为我是应用程序中每次搜索的 IndexSeacher 新手。垃圾收集器跟不上。
我刚刚完成了单例方法的实现,现在正在创建多个索引。
知道为什么会发生这种情况吗? IndexWriter 是我保持静态的。我从中得到 IndexSearchers。
I created an app using lucene. The server winded up throwing out of memory errors because I was new'in up an IndexSeacher for every search in the app. The garbage collector couldn't keep up.
I just got done implementing a singleton approach and now there are multiple indexes being created.
Any clue why this is happening? IndexWriter is what I am keeping static. I get IndexSearchers from it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有多个索引,只有多个段。随着时间的推移,Lucene 将索引分割成多个段,但如果您愿意,您也可以将其压缩。
请参阅此处和此处了解更多信息
You don't have multiple indexes, you just have multiple segments. Lucene splits the index up into segments over time, although you can compact it if you want.
See here and here for more info
您可能还想“新建”一个 IndexSearcher 并将其传递给周围,似乎您每次都在这里创建索引。
You also probably want to "new up" one IndexSearcher and pass it around, seems like you are creating the index every time here.