Lucene java.lang.OutOfMemoryError: Java heap space 错误

harryzyp 2008-11-13 02:47:41
我之前就几十条数据,现在有1W条数据,只要搜索频繁的话都会出现这错误
我的搜索代码是这样写的
searcher = new IndexSearcher(indexPath);
org.apache.lucene.search.Query query = null;
query = MultiFieldQueryParser.parse(queries, fields,ISAnalyzer.getAnalyzer(1));
hits = searcher.search(query, getFilters());
searcher.close();

有人说加环境变量JAVA_OPTS -Xms64m -Xmx512m,一点作用都没有
我用的tomcat,在windows下

哪位知道啊,郁闷很久了
...全文
264 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
harryzyp 2008-11-14
  • 打赏
  • 举报
回复
帖子怎么沉了...
wangju309 2008-11-14
  • 打赏
  • 举报
回复
你用JProbe工具测测,看看是什么对象占内存,能不能回收
harryzyp 2008-11-13
  • 打赏
  • 举报
回复
完整代码如下:
List results = new ArrayList();
IndexSearcher searcher = null;
try {
searcher = new IndexSearcher("e:/index");
org.apache.lucene.search.Query query = null;
query = MultiFieldQueryParser.parse(queries, "content",ISAnalyzer.getAnalyzer(1));
Hits hits = searcher.search(query, getFilters());
int hitLen = hits.length();
for (int i = 0; i < hitLen; i++) {
results.add(hits.doc(i));
}
hits=null;
}catch (Exception e) {
System.out.println("search:"+e.getMessage());
}finally {
if (searcher != null) {
// 关闭
try {
searcher.close();
} catch (IOException e) {}
}
}
harryzyp 2008-11-13
  • 打赏
  • 举报
回复
刚才测试好像是在我对Hit 做循环时报错
List results = new ArrayList();
int hitLen = hits.length();
for (int i = 0; i < hitLen; i++) {
results.add(hits.doc(i)); //就在hits.doc(i)中报错了
}
咋回事
brucest0078 2008-11-13
  • 打赏
  • 举报
回复
东西全加载到内存去过滤不好,
只把需要的小量精确数据拿出来...
_______-- 2008-11-13
  • 打赏
  • 举报
回复
应该是虚拟机内存太小了。把虚拟机内存调大点。
  • 打赏
  • 举报
回复
Lucene搜索没用过

不过java.lang.OutOfMemoryError: Java heap space 错误见过
楼主参考以下:
http://jetway.javaeye.com/blog/106741

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧