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

PrintSCP Releasing memory before its finished #35

Open
auspaco opened this issue May 1, 2019 · 1 comment
Open

PrintSCP Releasing memory before its finished #35

auspaco opened this issue May 1, 2019 · 1 comment

Comments

@auspaco
Copy link

auspaco commented May 1, 2019

PROBLEM:

When PrintSCP receives an N-Delete request it frees memory that may still be in use by the worker print thread, resulting in a memory violation. I think is related to a bug in the Image code which is already known.

WORKAROUND:

In PrintJob.cs line 241 the current code is:

        var thread = new Thread(new ThreadStart(DoPrint));

        thread.Name = string.Format("PrintJob {0}", SOPInstanceUID.UID);
        thread.IsBackground = true;
        thread.Start();

Replacing all of the above with:

         DoPrint();

Solves the issue for me, as it lets the printing finish before responding, and so the N-DELETE gets called when its safe to dispose of the memory (AFAIK). The only problem I can see is if the other services calls N-DELETE before waiting for a response then this can also fail, but I don't think this is likely. Ideally there should be some check in N-DELETE to makes sure it's safe to release everything - best in the underlying image classes so they can be deleted but not garbage collected.

@gofal
Copy link
Contributor

gofal commented Jun 30, 2019

This requires changes in fo-dicom.
Maybe we could add a PrintInProgress flag and a OnPrintComplete Action-List.
When printing, then the printInProgress flag is set. After printing the flag is removed and the OnPrintComplete actions are called.
The OnNDelete should not remove directly, but check if PrintInProgress is set. If yes, then an action to free the memory shall be added to the OnPrintComplete list.

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

No branches or pull requests

2 participants