[
https://issues.apache.org/jira/browse/ARIES-1603?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15470936#comment-15470936
]
Paul Thevenot commented on ARIES-1603:
--------------------------------------
Sure! We use it to delegate some methods execution and periodic treatments
asynchronously. We have a service shared by all bundles doing async operations.
final Runnable executor = async.mediate(target, Runnable.class);
executor.run();
async.execute().recover(promise -> {
try {
LOGGER.warn("Failed to execute asynchronous method using OSGi
Async service: {}", source, promise.getFailure());
} catch (InterruptedException ignore) {
}
return null;
});
That's true, we don't keep the mediated classes. Every time we need an async
execution, we call the mediate method. I just read the osgi r6 spec again and
you're right, it does says that the client may store them. Actually, our
implementation does not allow us to store them. I'll see if we could store them
and if it's not a problem because it means store an object for each
asynchronous method.
Anyway, I'm not sure that the fact that we store or not the mediated objects is
directly the cause of the issue. Actually, as a workaround, I've clone the repo
and removed the new ClassLoader() in the privmediate method. It's not leaking
anymore. What is the purpose of the classloader clone? The prevent an execution
after a service shutdown?
We had the issue with a few amount of asynchronous tasks repeating all the time
(our periodic treatments).
> Aries async classloader leak
> ----------------------------
>
> Key: ARIES-1603
> URL: https://issues.apache.org/jira/browse/ARIES-1603
> Project: Aries
> Issue Type: Bug
> Affects Versions: async-1.0.2
> Reporter: Paul Thevenot
>
> Using the async service with repeated tasks during one hour leads to an out
> of memory. It's due to the very large amount of class loaded (in 10 min we
> get 20000 classes loaded). The metaspace is growing indefinitely.
> It seems to come from the privMediate method of the AsyncService where the
> classloader of the target service is cloned.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)