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

JobEndCallbackManagerImpl consumes heap in the long run #51

Open
k2sd opened this issue May 29, 2017 · 1 comment
Open

JobEndCallbackManagerImpl consumes heap in the long run #51

k2sd opened this issue May 29, 2017 · 1 comment

Comments

@k2sd
Copy link

k2sd commented May 29, 2017

I'm afraid the completedExecutions field in the JobEndCallbackManagerImpl consumes heap if a lot of job executions get done without restarting the 'job end callback service.'

An execution is finished, the execution id is added to the map as follows:

@Override
	public synchronized void done(long jobExecutionId) {
		if (logger.isLoggable(Level.FINER)) {            
			logger.finer("Firing callbacks for job execution id: " + jobExecutionId);
		}
		completedExecutions.add(jobExecutionId);
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

There seems no method that reduces the size of the map, so I think it will eventually exhaust heap (Of course it depends on how many executions are done while the service is alive).

Is it necessary to check completed execution ids when calling the job-end-callbacks?

@k2sd
Copy link
Author

k2sd commented May 30, 2017

I'm not quite so sure but we might want to prevent completedExecutions from being added if there is no callbacks.

diff --git a/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/callback/JobEndCallbackManagerImpl.java b/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/callback/JobEndCallbackManagerImpl.java
old mode 100755
new mode 100644
index da64700..3fd33d3
--- a/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/callback/JobEndCallbackManagerImpl.java
+++ b/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/callback/JobEndCallbackManagerImpl.java
@@ -59,6 +59,9 @@
 
 	@Override
 	public synchronized void done(long jobExecutionId) {
+		if (callbacks.isEmpty()) {
+			return;
+		}
 		if (logger.isLoggable(Level.FINER)) {            
 			logger.finer("Firing callbacks for job execution id: " + jobExecutionId);
 		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant