创建大图时Neo4j内存不足错误

时间:2013-11-08 16:50:05

标签: java neo4j out-of-memory

我在java中使用Neo4j数据库,我需要在其中放入大量节点但是我的内存出错了。我设法通过每1000个节点提交一次事务来延迟内存不足,如下所示:

Transaction tx = graphDb.beginTx();
try
{   
   try (BufferedReader br = Files.newBufferedReader(Paths.get("page_links_en.ttl"), StandardCharsets.UTF_8)) {
   int n = 0;          
   for (String line = null; (line = br.readLine()) != null;) {
      n++;
      Node node = graphDb.createNode();
      node.setProperty("uri",line);
      if((n % 1000) == 0){                              
        tx.success();
        tx.close();                     
        tx = graphDb.beginTx()
      }
   }
}...

但不幸的是,这只是延迟了内存不足错误的时间。我确信这个问题与节点创建有关,并且app的其他部分没有其他内存泄漏。所以我想请求帮助解决这个问题。

提前谢谢。

0 个答案:

没有答案