Der folgende einfache Jersey Anruf Gegenstände in die Warteschlange Finalizer undicht: Jersey 2.x undichten Speicher (Finalizer) mit einfachen POST-Aufruf (Multithreaded)
public boolean startExperiment(Experiment experiment) {
final Client client = ClientBuilder.newClient();
Response response = null;
RunDescriptor runDescr = experiment.getRunDescriptor();
try {
final WebTarget webTarget = client.target(ExperimentController.getInstance().getRunnerUrl()).path("runs").path("startNewAsyncrun");
response = webTarget.request().post(Entity.entity(runDescr, MediaType.APPLICATION_JSON));
if (response != null && response.getStatusInfo().getStatusCode() != Status.CREATED.getStatusCode()) {
System.out.println("Error, Run not created! Response Info: " + response.getStatusInfo());
return false;
} else {
return true;
}
} finally {
if(response != null) {
response.close();
}
client.close();
}
}
Jersey versions with which I tested: 2.18, 2.20, 2.22.2, 2.23.1. The code is run from multiple threads (each thread running it once every minute, for example). Also closing Response and Client should not be necessary, added it jsut in case to test if it would help. Eclipse MAT shows Finalizer queue to be growing with Objects of type:
- sun.security.ssl.SSLSocketImplementation
- java.io.FileInputStream
- sun.net.www.protocol.https.DelegateHttpsURLConnection
- org.glassfish.jersey.client.ClientRuntime
- ZipFileInflaterInputStream
Any help or thoughts on the matter is really appreciated!
Sieht aus wie etwas, das Sie als ein Problem mit Trikot ablegen möchten. Nebenbei sei es empfohlen, 'Client'-Instanzen in einer Anwendung wiederzuverwenden, da sie teuer zu erstellen sind. –