Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threads of DICOM association remain in memory #2

Open
nroduit opened this issue Feb 7, 2021 · 0 comments
Open

Threads of DICOM association remain in memory #2

nroduit opened this issue Feb 7, 2021 · 0 comments

Comments

@nroduit
Copy link
Member

nroduit commented Feb 7, 2021

DICOM associations do not release properly. The TCPConnector lambda remains in memory even when everything is closed. After a certain number of iterations there are sometimes errors (changing to 20-50).

package org.dcm4che6.tool.echoscu;

import org.dcm4che6.conf.model.Connection;
import org.dcm4che6.data.UID;
import org.dcm4che6.net.AAssociate;
import org.dcm4che6.net.Association;
import org.dcm4che6.net.DicomServiceRegistry;
import org.dcm4che6.net.TCPConnector;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

public class MultipleEcho {
    public static void main(String[] args) throws Exception {
        String calling = "ECHOSCU";
        String called = "DICOMSERVER";
        String host = "dicomserver.co.uk";
        int port = 11112;
        for (int i = 0; i < 20; i++) {
            DicomServiceRegistry serviceRegistry = new DicomServiceRegistry();
            TCPConnector<Association> inst = new TCPConnector<>(
                    (connector, role) -> new Association(connector, role, serviceRegistry));
            CompletableFuture<Void> task = CompletableFuture.runAsync(inst);
            AAssociate.RQ rq = new AAssociate.RQ();
            rq.setCallingAETitle(calling);
            rq.setCalledAETitle(called);
            rq.putPresentationContext((byte) 1, UID.VerificationSOPClass, UID.ImplicitVRLittleEndian);
            Association as = inst.connect(new Connection(), new Connection().setHostname(host).setPort(port))
                    .thenCompose(as1 -> as1.open(rq))
                    .get(3000, TimeUnit.MILLISECONDS);
            as.cecho().get(3000, TimeUnit.MILLISECONDS);
            as.release();
            as.onClose().get(3000, TimeUnit.MILLISECONDS);
            task.cancel(true);
        }
        System.out.println("end");
    }
}

Breakpoint after the iterations:
Sélection_057

In TCPConnector the run hangs in selector.select(this::onReady);?
Sélection_058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant