Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak with BackgroundExecutor using BackgroundExecutorWrapper ThreadLocals (for scheduled tasks) #2859

Merged
merged 2 commits into from
Oct 18, 2022

Conversation

nPraml
Copy link
Contributor

@nPraml nPraml commented Oct 17, 2022

Hello @rbygrave ,
hello @rPraml ,

I created a PR with the fix of #2854.
Could you please check it?

@rbygrave the maven build does not work local on my machine, CsvReaderTest throws a java.time.format.DateTimeParseException: Text '01-Jan-2009' could not be parsed at index 3.
The test works only if I use -Duser.language="en".

Cheers
Noemi

}

@Override
public ScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit) {
return schedulePool.schedule(wrap(logExceptions(task)), delay, unit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, if we should keep it here. The task will be scheduled one time. But this may keep objects also long in memory.
Maybe the caller is responsible to pass a proper runnable/callable

Copy link
Member

@rbygrave rbygrave Oct 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure either - it almost looks like a 50/50 call to me.

If we do wrap() here it would be a problem if the delay is "a long time", and if that is a problem for a particular use case then what is the workaround? I don't see a nice workaround so that is suggesting to me that we don't wrap() here [and leave it up to the caller to wrap or not].

Copy link
Member

@rbygrave rbygrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, we just need agreement on whether to wrap() on the 2 schedule() methods.

@nPraml
Copy link
Contributor Author

nPraml commented Oct 18, 2022

Hello @rbygrave ,
we adapted the javadoc in BackgroundExecutorWrapper.
We would not use wrap in the two schedule methods.

@rbygrave rbygrave merged commit 7152cf6 into ebean-orm:master Oct 18, 2022
@rPraml rPraml deleted the backgroundexecutor-memory-leak branch August 10, 2023 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants