PowerShell: Import-PSSession and memory leak

Import-PSsession does cause memory leak because memory is not released when your script ends.
So use Remove-PSsession to clean up at end of the script. Works well except if your script terminates then the session is still left there. So use Try to encapsulate your code and use finally
In this day and age we assume garbage collection is automatic in Windows and the days of memory management when coding is gone. Well it isn’t. Its better than the C/C++ days when you code had to be memory efficient but the gaps of today are hidden because we have tons of memory to play with. And besides its still standard best practice to reboot your servers periodically.
Seems like a good idea for IoT to solve.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s