The class org.apache.ojb.broker.cache.ObjectCacheDefaultImpl has a flaw that can (and has in my case) cause an OutOfMemoryError.

It is a basic object cache. Objects stored in a hashtable keyed by strings constructed from Identity objects. It is even smart and uses SoftReferences so the cache doesn't get too big and fat thanks to the GC. There is one problem with this though.

The values of the hashtable are soft references so they are cleared, however the keys of the hashtable will not go away because they are still in the hash table! When doing a load process (inserting 5000+ records with unique keys) in a JVM with -Xmx8M, I receive an OutOfMemoryError after a few minutes.

A possibility would be to use the LRUMap and set a maximum, so your cache doesn't get too big
http://jakarta.apache.org/commons/collections/api/org/apache/commons/collections/LRUMap.html


But that has more disadvantages than advantages probably. I'm not in the mindset to solve this problem, so I am just disabling the cache during my load process. Just wanted to let people know.

Regards,
Todd Lindner




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



Reply via email to