help wantedquestion
Repository-Metriken
- Stars
- (6.985 Stars)
- PR-Merge-Metriken
- (Keine gemergten PRs in 30 T)
Beschreibung
Hi Folks,
I’m encountering a possible memory leak while using JavaCV for image resizing in a Spring-WebFlux application.
Environment Details:
- Kubernetes Pod: 8GB memory
- JVM Settings: -Xms=1024M, -Xmx=2048M
- Traffic: ~30 TPS on one pod
Issue: Memory utilization climbs to ~92% over a span of ~30 hours and then stabilises.
- I’ve ensured that all Mat objects are properly released and also employed PointerScope for memory management.
- JVM heap memory usage never exceeds 1GB.
Despite these efforts, memory usage continues to rise steadily over time. Below is the snippet of code used for resizing images:
try (PointerScope pointerScope = new PointerScope()) {
Mat mat = Imgcodecs.imread(inputMediaPath.toString());
Size size = new Size(width, height);
Mat resizedMat = new Mat();
Imgproc.resize(mat, resizedMat, size, 0, 0, Imgproc.INTER_AREA);
Imgcodecs.imwrite(outputMediaPath.toString(), resizedMat);
mat.release();
resizedMat.release();
// Tried both with and without pointerScope.deallocate(), but memory issues persist.
pointerScope.deallocate();
}
Any advice on resolving this issue would be greatly appreciated. I’ve tried several approaches but cannot pinpoint the root cause of the rising memory usage.
Thanks in advance for your help!
Best regards, Ravi