cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nils Verheyen (JIRA)" <>
Subject [jira] [Commented] (CAY-1776) OutOfMemory during lifecycle events
Date Wed, 05 Dec 2012 08:01:05 GMT


Nils Verheyen commented on CAY-1776:

Hi Andrus, the application is quite complicated so i hope the following explanation is enough.

Inside the application some image processing is performed inside threads. I'm using a fixed
thread pool of a maximum of 8 threads besides the main thread (Executors.newFixedThreadPool(8)).
Each thread (main thread and the 8 worker threads) contains one ObjectContext created when
an instance is initialized. This is done via DataContext.createDataContext();. Only in the
main thread one single listener is added to the object context.

void addFlickrPhotoPostSizePersistListener(Object listener, String methodName) {

        LifecycleCallbackRegistry registry = objectContext.getEntityResolver().getCallbackRegistry();
        registry.addListener(LifecycleEvent.POST_PERSIST, PhotoSize.class, listener, methodName);

The method is called only once! The ObjectContext on the main thread is created during application
launch and exists until the application is shut down.

Inside one of the 8 worker threads 256 Objects are created through one ObjectContext at max
and persisted to the database (mysql at the moment). After a worker is done the context is
not used anymore.

Inside the main thread thousands of Photo, PhotoSize and ProcessingJob objects are created
and persisted to db.

At the moment I use Cayennes stable release 3.0.2. I'll try the different approaches beginning
with #1.

I hope the explanation is enough, otherwise I try to extract some code.

Thank for the help,
> OutOfMemory during lifecycle events
> -----------------------------------
>                 Key: CAY-1776
>                 URL:
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Lifecycle Extensions
>    Affects Versions: 3.0.2, 3.1B1
>         Environment: Linux x64, Mac OS X Lion
>            Reporter: Nils Verheyen
>            Priority: Minor
> Inside in Cayenne 3.0.2 and DefaultEventManager in Cayenne 3.1 there
is the inner class Dispatch with the following code:
> synchronized (eventQueue) {
>                     eventQueue.add(new InvocationDispatch(
>                             eventArgument,
>                             subject,
>                             invocation));
>                     eventQueue.notifyAll();
>                 }
> Inside my code a event listener is added once, but inside the eventQueue multiple InvocationDispatch
objects are created and never thrown away. When persisting thousands of objects the eventQueue
is filled up leading to OutOfMemory exceptions.
> Regards,
> Nils

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message