The PowerShell script below runs continuously and generates output. This is a simplified version of a script which which I use to monitor processes running on my computer.
while ($true) {
get-date
start-sleep 1
}
I run this process in the the PowerShell ISE (Windows 10, PowerShell v5.1).
When this script runs, the memory used by the PowerShell ISE (powershell_ise.exe) increases continuously. Stopping the process stops the memory utilization increase.
Adding clear-host
to the process does not help. The script below also uses an ever-increasing amount of RAM.
while ($true) {
clear-host # <=== Added
get-date
start-sleep 1
}
How can I limit the memory consumed by this continuously running process?