slice.util.loadVolume(path) freezes after reading 5 images

I’m using loadVolume to read 6 nii files, extrat their array and save it in a dictionary.
It works reading 5 of them but freezes on reading the 6’th one.

The 6’th file loads okay if I import it as a file in slicer manually, so the issue is not with the file.
Also if I remove reading of first file, it can also read the 6’th one, so it seems like it has some issues with lack of memory or some resource usage.
I checked the memory usage in task manager and it is (52% of ram ~ around 15G) on slicer.

Any ideas?