You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Craig Andrews <cr...@simplyspiffing.com> on 2004/07/26 17:39:50 UTC

OJB runaway lock objects

Hi,

I am looking for help debugging a nasty problem with a JBoss app I am 
building, using OJB as the persistence mechanism. I have a very simple 
set up, with only a single object, and the following session bean:

public class ProductAdmin extends SessionBean {

	private Implementation odmg = null;
	private Database db = null;

	public void ejbCreate() {
		odmg = OJB.getInstance();

		db = odmg.newDatabase();
		try {
			db.open("default", Database.OPEN_READ_WRITE);
		} catch (ODMGException e) {
			e.printStackTrace();
		}
	}

	public void ejbRemove() throws EJBException, RemoteException {
		try {
			if (db != null) db.close();
		} catch (ODMGException e) {
			throw new EJBException(e);
		}
		odmg = null;
	}

	public Integer create() throws Exception {
		Product p = new Product();
		Transaction tx = odmg.newTransaction();
		tx.begin();
	
		try {
			tx.lock(p, Transaction.WRITE);
			tx.commit();
		} catch (Exception e) {
			tx.abort();
			throw (e);
		}

		return p.getId();
	}

}


If I then run the create method a few thousand times, it becomes
apparent that there are thousands of 
org.apache.ojb.odmg.locking.ObjectLocks and
org.apache.ojb.odmg.locking.LockEntry objects that cannot be garbage
collected. The net result is that after ~90,000 objects are written to
the database, there is no memory left for the JVM!

The system is supposed to be supporting a userbase of over 200,000, so
this many writes is quite feasible in a short space of time.

Is there anything I'm doing wrong with the transactions? I have followed 
the tutorials as closely as I can and have reached the stage where I 
wouldn't be able to see the woods if there were one, due to these trees 
everywhere.

Thanks!

-- 
Craig Andrews <cr...@simplyspiffing.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org