[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ojb-user
Subject:    Re: How to shutdown OJB when stopping web context.
From:       <mkalen () apache ! org>
Date:       2005-03-24 15:22:49
Message-ID: 4242DB49.3050407 () apache ! org
[Download RAW message or body]

Nathan Smith wrote:
> I cannot quite remember what the problem was, but it had something to with
> Iterators not returning all objects or Collections being returned containing
> no objects, but that’s better left for another time at the moment.

Aha, this "smells" like objects of class OJBIterator returned when using 
PB-API and report-queries or iterating Collections that are using proxy 
objects in OJB.

In OJB 1.0.x the API will specify Iterator as return type so you have to 
do a somewhat ugly cast to (OJBIterator) and call #releaseDbResources() 
if you want to free resources from unexhausted [*] iterators before 
#finalize() and auto-release.

[*] You can also "exhaust" the iterator by always iterating to the end, 
which will also trigger a fast release of any DB-resources (including 
ResultSet and thus implicitly Connection) when the iterator reaches the end.

It could be because of constructs like:
while (ojbiter.hasNext()) {
	ojbiter.next();
	if (condition) {
		break out; <== late release, did not exhaust iterator
	}
}

Or:
ojbiter = broker.getReportQueryIteratorByCriteria(crit);
Object onlyOneExpected = ojbiter.next();
// late release, did not exhaust iterator


If you are using Oracle it should become obvious very fast if you have 
delayed release of resources in some Iterator objects, as this will keep 
the Oracle server-side cursors allocated and you will very fast get an 
SQLException with MAX_CURSORS_EXCEEDED.

> Any more suggestions?

You could also try using the abandoned-config in DBCP and set a very 
short threshold time to log connection leaks, although it's difficult to 
say what the threshold should be if you really want to hold on to some 
connections a bit longer.

Regards,
  Martin

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic