Keep heap lean during remote polling #4599
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #4598.
The polling in
MessageChannelPartitionHandler
repeatedly fetches the running job execution with all associated step executions from the job repository. At the moment, it also retains references to step executions that have completed since the last iteration. This can accrue a lot of heap memory as each step execution holds references to a job execution, and that job execution holds references to all step executions.This PR proposes not to retain any references to step or job executions while there are still running step executions. Instead, the step executions from the last iteration are used to build the result. This works as completed step executions are not expected to change after completion. And it reduces the memory foot print as the objects created in intermediate iterations can be handled by the garbage collector.
No test is added or changed as the changed code is already covered by appropriate tests.