Here’s a script I tried at local machine:
tf = transforms.Compose(
    [transforms.Resize((1000, 1000)),
     transforms.PILToTensor()])

for fname in list:
    with Image.open(fname) as img_pil:
        img_pil = tf(img_pil)
        img_pil = img_pil.type(torch.float32)
    print(psutil.virtual_memory().available)

and here’s output (swap is disabled):
54919290880
54912282624
54912274432
54900854784
54903816192
54903750656
54904684544
54904807424
54904815616
54904860672
54904860672
54904729600
54904963072
54904954880
54904762368
54904885248
54904717312
54904791040
54904856576
54904930304
54904983552
54904717312
54905122816
54904283136
54904274944
54904217600
54904332288

as you can see memory released just fine