Link to home
Start Free TrialLog in
Avatar of Mauro Cazabonnet
Mauro CazabonnetFlag for United States of America

asked on

Powershell continous loop memory consumption

Hi I'm running a continuous loop, and running into a memory issue

$date=(get-date).day
while($date -eq ((get-date).day))
{
   
    Start-Sleep -Seconds 10
   

}

memory consumption of powershell.exe increases over time is there a way to keep it in check for this simple loop?
ASKER CERTIFIED SOLUTION
Avatar of Dustin Saunders
Dustin Saunders
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you really run only this simple loop? Certainly not - and then the other stuff might be the culprit.
If all you do the loop for is to wait, then you should just run a single sleep with the correct number of seconds.
Avatar of Mauro Cazabonnet

ASKER

Awesome thx!...
Thx...
Does that really help?
i ran this simple loop and the [GC.System]::Collect does prevent the powershell.exe thread from increasing in memory. (You can test yourself)
I have it running every 15 minutes on my current service
I do have a complex process running based on user demand, and the working memory on the iis server is not increasing in size