2017-08-03 48 views
0

我试图坚持很多数据,但我总是得到一个“memoryOutException”。 我已经尝试冲洗,清除,关闭...所有的解决方案在SOF中提出的一切..没有工作,我的记忆不断增长,坚持/承诺进行得越来越慢...有Hibernate ogm内存泄漏? (或者不是很好)

使用
public class Insersecao1 { 

private static EntityManagerFactory emf; 
private static SessionFactory factory; 

public static void main(final String[] args) throws Exception { 

    File pathFile = new File("D:\\Dados lab\\Database-json"); 
    AnalyzedCommit analyzedCommit = null; 


    emf = Persistence.createEntityManagerFactory("hikePu"); 
    EntityManager entityManager = emf.createEntityManager(); 
    entityManager.getTransaction().begin(); 

    int count = 1; 
    for (File f : pathFile.listFiles()) { 

     analyzedCommit = ... ; 
     entityManager.persist(analyzedCommit); 

     if (count % 75 == 0) { 

      entityManager.getTransaction().commit(); 
      entityManager.close(); 
      entityManager = emf.createEntityManager(); //Tried create a new one 
      entityManager.getTransaction().begin(); 
     } 

     count++; 
     System.out.println(count); 

    } 
} } 

在行家:

<dependency> 
     <groupId>org.hibernate.ogm</groupId> 
     <artifactId>hibernate-ogm-neo4j</artifactId> 
     <version>5.0.4.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.jbossts</groupId> 
     <artifactId>jbossjta</artifactId> 
     <version>4.16.6.Final</version> 
    </dependency> 

,坚持:

<persistence-unit name="hikePu" transaction-type="RESOURCE_LOCAL"> 
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider> 
    <properties> 
     <property name="hibernate.ogm.datastore.provider" value="neo4j_embedded" /> 
     <property name="hibernate.ogm.datastore.database" value="EasyDB" /> 
     <property name="hibernate.ogm.neo4j.database_path" value="D:\Dados lab\mydb" /> 
     <!--   <property name="hibernate.ogm.neo4j.database_path" value="mydb" />--> 
     <property name="dbms.allow_format_migration" value="true" /> 
    </properties> 
</persistence-unit> 

回答

0

据从我的分析中可以看出,它来自Neo4j,而不是OGM。使用外部Neo4j服务器可以看到OGM内存使用情况稳定(我现在正在运行一个800万个实体的插入)。

我建议你升级到Hibernate OGM 5.1.0.Final,并使用neo4j_http数据存储提供程序或neo4j_bolt数据存储协议(我推荐使用Bolt)的外部Neo4j服务器。

无论如何,我认为这是一个更好的解决方案,因为您可以访问漂亮的Neo4j控制台等等。

有关如何配置对Neo4j服务器的访问的更多信息,请参阅https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/#_configuring_neo4j