Skip to content

Threads of DICOM association remain in memory #2

@nroduit

Description

@nroduit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions