Smells like a memory leak.
If you (or anyone) are serious about this, please for the love of God allow for multithreading (even if at the expense of efficiency), put some SIMD in there, or better yet utilize GPUs.
So much of Dicom image handling is done single thread and it's so silly.
I'd guess it's probably safer than using AI directly.