Fix memory leak in HttpLoggingFilter #1206
Open
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.



I've been investigating the rather high memory usage of the MapRoulette backend. I looked at the objects on the heap and noticed that there are a surprising number (9.2M when I checked) of instances of org.slf4j.helpers.BasicMarker.
These Marker objects are internally cached by the MarkerFactory. I think the expected pattern is to create a small, statically known set of Markers in your application; creating a distinct Marker per request means that memory usage grows without bound.
This PR removes the marker and instead just embeds the request UUID directly into the log message. If we want the UUID to also be automatically included in other log messages inside the request context (which the Marker approach does not accomplish), we should store the UUID in MDC, which uses a thread-local context that gets cleaned up when the request is over.