有 Hibernate ogm 内存泄漏吗? (或者某些东西没有很好地关闭)

has Hibernate ogm memory leak? (Or something is not closing well)

我试图保留大量数据,但我总是得到 "memoryOutException"。 我已经尝试过刷新、清除、关闭... SOF 中提供的各种解决方案的所有内容.. 并且 none 有效,我的记忆力不断增长,persist/commit 越来越慢...

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);

    }
} }

在 Maven 上使用:

    <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>

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

我建议您升级到 Hibernate OGM 5.1。0.Final 并使用带有 neo4j_http 数据存储提供程序或 neo4j_bolt 数据存储协议的外部 Neo4j 服务器(我建议使用螺栓)。

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

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