Fix Powershell error: System.OutofmemoryException (incl. NAV PSM wrapper)

powershell_featured
FacebookTwitterGoogle+LinkedInWhatsAppEvernoteShare

It might be that you are trying to execute some large powershell processes and you get this System.OutOfMemoryException error. It happened to me when working with the new (still unreleased) version of This is Merging! for Dynamics NAV.

If you are suffering from the same issue, what Powershell is telling you is that the Powershell session is using more memory than allowed by the system.

And since Waldo released a Powershell Wrapper for NAV (which is what TIM uses) and I was getting this error, I thought it would be interesting to make a quick blog post about it.

In order to find out how much memory you have assigned you can do it by typing the following in a powershell command prompt (preferibly with admin rights):


get-item wsman:localhost\shell\maxmemorypershellmb

get-item_out_of_memoryIn my case it is telling me that the maximum memory allowed per shell is 1024MB. It was not enough in my case I have enough memory in my computer, so I decided to assign more. And I did :-)

In order to do so, type the following command:


set-item wsman:localhost\shell\maxmemorypershellmb 2048

set-item_out_of_memory
Needless to say you can modify the value at the end of the instruction to suit your needs.

Once we have changed that we can check if the value has actually been changed by executing the first command:
get-item_out_of_memory_after_changeSo it is changed. Nice :-)

 

Leave a Comment.