Submit a ticketCall us

Systems Monitoring for Dummies
Our new eBook will teach you the fundamentals and help you create monitors and alerts that are effective, meaningful, and actionable. Monitoring is more than a checkbox on your to-do list. This free eBook will give you practical advice to help you succeed in all aspects of monitoring – discovery, alerting, remediation, and troubleshooting. Don’t miss out on this indispensable resource for newbies, experienced IT pros, and everyone in between. Register Now.

Home > Success Center > Server & Application Monitor (SAM) > PowerShell components return 'System.OutOfMemory' exception'

PowerShell components return 'System.OutOfMemory' exception'

Updated September 18, 2017

Overview

This article explains issues regarding Windows PowerShell components that return a System.OutOfMemory exception, and includes ways to resolve those issues. Please note that SolarWinds does not configure/write/support custom PowerShell scripts.

Environment

  • All versions of SAM

Cause 

Processes that run PowerShell scripts have a set memory limitation — the default is 150 MB. If a few scripts return very large results, or a large amount of scripts run simultaneously and consume memory past the limit, System.OutOfMemory exceptions may occur.

Resolution

To check how much memory is allocated to the PowerShell process, run this command from the elevated PowerShell prompt:
 

get-item wsman:localhost\Shell\MaxMemoryPerShellMB
 

To increase the amount of allocated memory to resolve issues related to running a few scripts that return a large amount of results, run this command from an elevated PowerShell prompt:
 

set-item wsman:localhost\Shell\MaxMemoryPerShellMB AmountInMB


If running a large number of PowerShell scripts and System.OutOfMemory errors occur, add a garbage collection line to scripts that run at a regular interval to release the process memory. This can help prevent scripts from consuming memory past the maximum limit by freeing memory at the end of script execution. To learn more about garbage collection, click here.

 

Disclaimer: Please note, any content posted herein is provided as a suggestion or recommendation to you for your internal use. This is not part of the SolarWinds software or documentation that you purchased from SolarWinds, and the information set forth herein may come from third parties. Your organization should internally review and assess to what extent, if any, such custom scripts or recommendations will be incorporated into your environment.  You elect to use third party content at your own risk, and you will be solely responsible for the incorporation of the same, if any.

 

Last modified

Tags

Classifications

Public