orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2882)

Open gputti opened this issue 13 years ago • 12 comments

orientdb-1.3.0-SNAPSHOT, couldn't find build.number file.

What steps will reproduce the problem?

  1. keep on inserting an object to database. use "OObjectDatabaseTx". Around 330K records, It fails with out of memory error.

no custom setting. default installation and started server.

What is the expected output? What do you see instead? keep inserting docs at speeds you mentioned in web page. but can't see 2K inserts/sec.

Error: I am evaluating Orientdb & mongodb for our app. first of all examples given are very simple examples and they aren't much help if someone wants to do a bit serious stuff. how to persist if I don't know about object at the time of persisting to db?

Anyway, I ran several tests since morning, but consistently getting out of memory error. things I tried:

  • resetting connection after every 100K inserts. but that doesn't help.
  • use file system for temp database (by changing orientdb-server-config.xml file. no use.

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2882) at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390) at java.lang.StringBuffer.append(StringBuffer.java:224) at javassist.util.proxy.RuntimeSupport.makeDesc(RuntimeSupport.java:204) at javassist.util.proxy.RuntimeSupport.makeDescriptor(RuntimeSupport.java:155) at javassist.util.proxy.ProxyFactory.getMethods(ProxyFactory.java:1069) at javassist.util.proxy.ProxyFactory.getMethods(ProxyFactory.java:1046) at javassist.util.proxy.ProxyFactory.makeSortedMethodList(ProxyFactory.java:800) at javassist.util.proxy.ProxyFactory.computeSignature(ProxyFactory.java:808) at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:397) at com.orientechnologies.orient.object.enhancement.OObjectEntityEnhancer.getProxiedInstance(OObjectEntityEnhancer.java: 97) at com.orientechnologies.orient.object.db.OObjectDatabaseTx.newInstance(OObjectDatabaseTx.java:115) at com.orientechnologies.orient.object.db.OObjectDatabaseTx.newInstance(OObjectDatabaseTx.java:86) at com.orientechnologies.orient.object.enhancement.OObjectEntitySerializer.serializeObject(OObjectEntitySerializer.java :113) at com.orientechnologies.orient.object.db.OObjectDatabaseTx.save(OObjectDatabaseTx.java:362) at com.orientechnologies.orient.object.db.OObjectDatabaseTx.save(OObjectDatabaseTx.java:307) at at org.datanucleus.api.jpa.JPAEntityTransaction.commit(JPAEntityTransaction.java:103)

any help, to show that it works at least inserting 20K/sec is highly appreciated.

Thanks Gopi Putty

gputti avatar Dec 11 '12 02:12 gputti

here is the file .zip file I used "orientdb-1.3.0-20121122.023959-92-distribution.zip" for installation.

gputti avatar Dec 11 '12 02:12 gputti

Hi, probably you're not freeing the memory in the right way. Can you post here the code you use for insertion? Did you follow the guidelines in: http://code.google.com/p/orient/wiki/PerformanceTuning#Massive_Insertion ?

lvca avatar Dec 11 '12 10:12 lvca

HI Luca thanks for reply. here is my code. I am using datanucleus layer (I created orientdb driver for it) I tried avoiding tr for every insert (making only once for 100K ) still getting 'out of memory error'. I run on mac with eclipse

here is my code

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("orient");
    EntityManager em = emf.createEntityManager();
    for (int i=0; i < 1000000; i++) {
        EntityTransaction tx = em.getTransaction();
        try  { tx.begin();
            Product product = new Product("test prod ", "descr of test prod", 20.00);
            em.persist(product);
            tx.commit();
        }
        finally
        {  }
    em.close();

and while persisting OObjectDatabaseTx connection = (OObjectDatabaseTx) mconn.getConnection(); ODatabaseRecordThreadLocal.INSTANCE.set(connection.getUnderlying()); try { connection.save(op.getObject()); } catch (Exception e) {

and here is getConnection public Object getConnection() {
OObjectDatabaseTx connection = (OObjectDatabaseTx)conn; if (connection == null || connection.isClosed() ) { OObjectDatabaseTx db = new OObjectDatabaseTx("remote:localhost/demo"); conn = db.open(username, password);
} return conn; }

gputti avatar Dec 11 '12 13:12 gputti

Your code is waaay slow. Few suggestions:

  • use the pool, don't get a remote-connection every time!
  • don't use a tx per object! Rather remove the tx at all
  • use the massive insert intent

lvca avatar Dec 11 '12 13:12 lvca

OK. except using pool, I am doing other 2 already. As I already mentioned, I tried creating transactions for every 100K inserts. it didn't help. and I am NOT getting remote connection per every object. I keep using same connection. I only showed the way I am getting connection.

I will try 'massive insert intent' & pool let you know.

gputti avatar Dec 11 '12 18:12 gputti

Between "doesn't work with 100k" and "execute 1 tx per record" there is room to find the best.

Start tying with 10k, then 5k, etc.

With remote protocol the client keeps the record in memory until the commit() is called. This is the reason.

lvca avatar Dec 11 '12 18:12 lvca

Thanks for all help so far, but problem still persists. getting error "at com.orientechnologies.orient.core.memory.OMemoryWatchDog.run(OMemoryWatchDog.java:89)"

I am using pool, and trying to commit once per 100K. none of them works. here is my code. (I am giving only relevant lines from different methods and classes)

-- getting connection OObjectDatabaseTx db= OObjectDatabasePool.global().acquire(url, username, password); db.declareIntent(new OIntentMassiveInsert());

-- closing if (count > 100000) count =0; ((OObjectDatabaseTx)conn).commit(); ((OObjectDatabaseTx)conn).close();

So,not sure what else I can do. One thing confusing is: even after commit, if objects still reside in cache memory? How do I know that?

And secondly, even when I run for 10K or 20K I see speeds below 5K inserts/sec only. thanks Gopi Putty

gputti avatar Dec 11 '12 20:12 gputti

Hi, but what release are you using? Please use the 1.3.0-SNAPSHOT (final at days).

Lvc@

On 11 December 2012 21:47, gputty [email protected] wrote:

Thanks for all help so far, but problem still persists. getting error "at com.orientechnologies.orient.core.memory.OMemoryWatchDog.run(OMemoryWatchDog.java:89)"

I am using pool, and trying to commit once per 100K. none of them works. here is my code. (I am giving only relevant lines from different methods and classes)

-- getting connection OObjectDatabaseTx db= OObjectDatabasePool.global().acquire(url, username, password); db.declareIntent(new OIntentMassiveInsert());

-- closing if (count > 100000) count =0; ((OObjectDatabaseTx)conn).commit(); ((OObjectDatabaseTx)conn).close();

So,not sure what else I can do. One thing confusing is: even after commit, if objects still reside in cache memory? How do I know that?

And secondly, even when I run for 10K or 20K I don;t see speeds below 5K inserts/sec. thanks Gopi Putty

— Reply to this email directly or view it on GitHubhttps://github.com/nuvolabase/orientdb/issues/1210#issuecomment-11262923.

lvca avatar Dec 11 '12 23:12 lvca

I am using latest I believe as I mentioned above. here is the file .zip file I used "orientdb-1.3.0-20121122.023959-92-distribution.zip" for installation.

gputti avatar Dec 11 '12 23:12 gputti

and by the way can you point me in the code where exactly it writes to db? I mean writing to disc

gputti avatar Dec 11 '12 23:12 gputti

The only way to speed up things is to use the "local" protocol avoiding the TCP/IP layer. You can embed a server inside your app to use Studio and other tools: http://code.google.com/p/orient/wiki/EmbeddedServer

In this way you should notice at least x3 up to x10 performance than remote. But depends by your HW.

Lvc@

lvca avatar Dec 12 '12 00:12 lvca

something must be seriously wrong with either my code or orientdb. i switched to local database and i don't see any improvement.

gputti avatar Dec 12 '12 01:12 gputti