Hello list readers,

I'm running into a memory problem with OJB on a long running server. After
a couple of weeks the heap has grown in size from +- 150 MB to over 500
MB. Today I used the "jmap" tool that comes with je JDK to actually dump a
heap histogram:

189072640       107     org.apache.ojb.broker.PBStateListener[]
109750848       4572952 java.lang.ref.WeakReference
73035968        4564748
org.apache.ojb.broker.accesslayer.RsIterator$ResourceWrapper
27267184        22219   byte[]
25734504        302777  char[]
7466688 311112  java.lang.String
7442584 57688   * ConstMethodKlass
4159032 57688   * MethodKlass

189 MB is taken up by just 107 PBStateListener arrays! If we add up the
majority of WeakReference and RsIterator$ResourceWrapper instances we end
up with a leak of more than 300 MB, just about the size of the unexpected
heap growth we have been experiencing.

After analysing the OJB source code, I found that the PBStateListener
management in PersistenceBrokerAbstractImpl might be suspect. The arrays
that store the listeners (permanent and temporary) only seem to be able to
grow. The "removeListener" method is never actually called, and
considering the inefficiency of the algorithms used to add and remove
listeners I suspect that these methods where never meant to manage large
amounts of active listeners. The "removeAllListeners" method only seem te
be called when closing and destroying the PersistenceBrokerImpl instance.

The "addListener" method is called on every query though, so the size of
the arrays after a couple of weeks does not surprise me.

WeakReferences are used to make sure no references to the actual
PBStateListener implementors are leaked, but the week references
themselves (and the wrappers around them) are never removed, thus causing
the PBStateListener arrays to keep growing.

If this analysis is correct, I don't understand why nobody else is having
this problem. I must be doing something radically different (more stupid?)
than most other OJB users. Is there some other way these arrays are
supposed to get freed that I'm not using because of a bug in my code? If
so could you point me in the right direction where I might begin looking
for problems?

As you can imagine this is a serious performance problem for us, so I
would very much appreciate any help or advice.

Regards,
Pieter.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to