Skip to content

Out of memory error when running replace_identifiers on large number of files #301

Description

@lbicknes-umn

I am working with a team that is evaluating using this tool to de-identify DICOMs. The current script that we are testing with is essentially the following:

dicom_files = glob.glob(os.path.join(input_folder, "**", "*.dcm"), recursive=True)

items = get_identifiers(dicom_files)

# Clean the files
replace_identifiers(
        dicom_files=dicom_files,
        deid=recipe,
        strip_sequences=False, 
        ids=items,
        remove_private=True, 
        output_folder=output_folder, 
        overwrite=True,
        save=True,
)

Some of the operations that we will need have been removed in an attempt to get the script to complete (i.e., custom functions on the "items"). I have not included the recipe file, but using the default recipe results in the same behavior.

We have a large number of files in the input directory (e.g., 4-6 GB of total data), the script will consume 20+ GB of RAM. I also attempted to use the branch that skips the pixel data, and that did not change the behavior.

If a loop is created, and each DICOM file is cleaned individually with a manual delay it seems that the garbage collector will run and the total amount of memory is much lower. It seems that there is a memory leak.

I have attempted to profile the code and library without much luck.

Has this been observed by any other users? Is there a workaround? Possibility of a fix?

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