Closed MatthiasZerau closed 1 year ago
The counter used by Netty has been shadowed by the wrap method returned by the response decorator
The leak test works when that line is changed to
return dataBuffer;
so Netty could decrease the counter of the databufffer (using the release() method) instead of using the wrapper, leaving the other one with a count > 1.
Anyway, I am checking the implementation to get some improvement apart from removing the issue. Maybe we can reduce the memory footprint.
This chart looks better. You can see a sawtooth shape representing automatic GCs to release heap memory. I've left the app running sometime and the heap memory used decreased back to normal.
Closing in favor of #2886
When running Spring cloud Gateway with the LocalResponseCache active out of memory errors occur after after some time the application is running. The OOM happen while Netty trying to allocate native memory, for example:
Tracking down the issue I came to the conclusion that the LocalresponseCache may be the root of this issue. Once I disabled this filter, the OOM where no longer observable.
Java 17 Spring Boot 3.0.3 Spring Cloud 2022.0.1
A reproducible example can be found here. Just run
gradlew build
from the command line. The unit testLocalResponseCacheEnabledTests
is expected to fail. The log output of the test should contain errors similar to the following one: