The way Jira cleans up some of it's request caches can lead to memory leaks for code executed outside of HTTP threads - caesium jobs or plugin-supplied long running threads.
It applies to all request-scope caches provided by JiraAuthenticationContextImpl (AuthenticationContextImpl) and managed by JiraThreadLocalUtils.
Jira API provides plugin vendors with a way to execute code outside of HTTP requests scope with OffRequestThreadExecutor
It's supposed to properly initiate and destroy request caches.
JiraAuthenticationContextImpl.clearRequestCache(); is called on preCall, but not on postCall
Because of that request caches will not be cleaned up until the consecutive run of the job on the same java thread.
Request caches are being cleaned properly after a plugin-supplied code is executed.
Request caches are not cleaned and accumulate lots of unneeded objects in memory.
Calling JiraAuthenticationContextImpl.clearRequestCache(); would ensure that a job is not leaving anything behind.