Ich habe das folgende Code-Snippet. Einfacher Dienst, der ein Bild zurückgibt, wenn der Endpunkt aufgerufen wird.Jersey Speicherleck?
@GET
@Path("/categories/{category}/image")
@Produces("image/jpeg")
@UnitOfWork
public StreamingOutput getCategoryImage(@PathParam("category")Category category){
//foo service will return an Optional
return fooService.getImage(category).map(new Function<InputStream, StreamingOutput>() {
@Override
public StreamingOutput apply(InputStream inputStream) {
return (StreamingOutput) output -> BarResource.this.copyAndClose(inputStream, output);
}
})
.orElseThrow(NotFoundException::new);
}
//Originally this method did not exist, but I am trying this to close the 'leak'
private long copyAndClose(InputStream inputStream, OutputStream outputStream) throws IOException{
try(InputStream temp = inputStream; OutputStream tempOut = outputStream) {
return IOUtils.copy(temp, tempOut);
}
}
jedoch durch einen Stresstest, nannten wir diese 1600 mal/sec für ein paar Sekunden und die Speichernutzung in unserem Docker Container Himmel hochgeschnellt (von etwa 300 einen Gig auf über) können wir die Xmx eingestellt haben 512 aber die Erinnerung steigt weiter.
Fehle ich hier etwas? Wir benutzen Dropwizard und Jersey.