Blender free up memory using command line

Note: This is my first post, so if my title is not appropriate, please let me know what an alternative could be for more relevant answers :)

I am rendering a scene for someone(so no way for me to optimize the scene or anything like that) and I'm running into an issue where blender seems to be running out of memory and becomes unresponsive.

As a countermeasure I have started using the console, and this seems to be marginally more effective, I can render about 4 frames before the subsequent render just starts hanging.

When I use the command:

blender -b "path/to/blendfile" -s 50 -e 55


I get this error response immediately:

My workaround has been to render each frame individually using this command:

blender -b "path/to/blendfile" -f 50


This has been effective for about 4 frames, after which doing frame 55, the process just hangs and I need to restart my pc to be able to do 4 more frames again.

My question is, is there a way(perhaps a command) to free up memory blocks after every 4th frame or so, to prevent the need to restart my pc each time?

Some PC & Memory Specifications: OS: Windows 10

RAM: 16GB

GPU: RTX 3070 Ti

CPU: Ryzen 5 2600x

The usage statistics at the point of the render hanging:

• It might be helpful to know: what OS are you using, and how much RAM does the machine have in total/what else is using RAM, and how much (to determine if, e.g., is it a single especially expensive frame exhausting RAM, or is the memory just not being collected in between each cmd line invocation of Blender)? Sep 3, 2021 at 10:23
• @NeverConvex I'll update the question with the requested info thanks. Sep 3, 2021 at 10:28
• Also: how are you doing blender -b "path/to/blendfile" -f 50 currently? Are you manually invoking this from command line yourself for each frame, or did you write a small bash-or-powershell script to loop over calling Blender on each individual frame? Sep 3, 2021 at 10:31
• @NeverConvex I do this manually each time. Since it hangs, I don't think I should try to automate the script execution just yet Sep 3, 2021 at 10:33
• Thanks! If you're invoking manually, I'm surprised the memory blocks are never freed. I wonder if the Blender processes are not actually closing properly, and maybe forcibly terminating them would cause the memory to be freed? I also notice someone asked a similar question in blender.stackexchange.com/questions/158191/…. The discussion there seems to suggest that a slight variation on the command line arguments didn't fix the error, but did generate (all?) the output files, so might try that Sep 3, 2021 at 10:42