Getting System.OutOfMemoryException when script is packaged into PS 5.1 .exe

PowerShell Pro Tools
Packaging with:
Console application
DotNetVersion = ‘v4.8.0’

My script works fine from a terminal or from within VS Code. However when I package it into a PS 5.1 .exe I get a ‘System.OutOfMemoryException’ errors.

It happens when I do a Import-CSV of some large ~20MB csv files.
Basically I download several .Zip files using Invoke-WebRequest, expand them and process the data into a CSV report. I launch up to 3 Runspaces.

Is there a way to set/increase memory? Any recommendations?

I’d recommend trying to force the architecture of the executable to be x64 to see if that resolves it. .NET will default to x86 by default.