Skip navigation
VMware

This Question is Answered (go to answer)

912 Views 13 Replies Last post: Feb 23, 2011 5:21 AM by crosen RSS
crosen Hot Shot 140 posts since
Sep 15, 2008
Currently Being Moderated

Feb 21, 2011 1:24 PM

Exception of type 'System.outOfMemoryException' was thrown

Trying to run a script to collect snapshot info.  Sometimes it will work successfully and other times I get this error...

 

Get-View : 2/21/2011 4:12:48 PM    Get-View        Exception of type 'System.Ou
tOfMemoryException' was thrown.
At C:\MyDocs\work\Virtualization\VMWare\VMware_Healthcheck\Notes_Fields\TCOMDB_
Data\005c_snapshot-size-vcell03.ps1:17 char:16
+ $vms = Get-View <<<<  -ViewType VirtualMachine
    + CategoryInfo          : NotSpecified: (:) [Get-View], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
   n.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView

 

 

Thanks.

LucD Guru User Moderators vExpert 9,015 posts since
Oct 31, 2005
Currently Being Moderated
1. Feb 21, 2011 2:13 PM in response to: crosen
Re: Exception of type 'System.outOfMemoryException' was thrown

Would that by any chance be the script from this post Gathering snapshot size info takes 10+ hours ?

That script uses a recursive function and depending on the size of the environment and the number of snapshots it could consume quite a bit of memory I'm afraid.

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
LucD Guru User Moderators vExpert 9,015 posts since
Oct 31, 2005
Currently Being Moderated
3. Feb 21, 2011 5:02 PM in response to: crosen
Re: Exception of type 'System.outOfMemoryException' was thrown

That's the script I meant.

The filter Get-SnapHash is used recursively.

 

Do you have many snapshots on your guests ?

Are you perhaps running the script on a client that has a rather low amount of physical memory ?

Can you check with the Task Manager or Sysinternal's Process Explorer how much memory your PS script claims ?

Do you run the script from the PowerCLI prompt ? Or from something like PowerGUI ?

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
LucD Guru User Moderators vExpert 9,015 posts since
Oct 31, 2005
Currently Being Moderated
5. Feb 21, 2011 5:53 PM in response to: crosen
Re: Exception of type 'System.outOfMemoryException' was thrown

Are you running this in the 64-bit version of PowerCLI ?

If not, can you give it a try ?

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
Dave.Mishchen… Guru User Moderators vExpert 11,905 posts since
Nov 15, 2005
Currently Being Moderated
7. Feb 21, 2011 6:51 PM in response to: crosen
Re: Exception of type 'System.outOfMemoryException' was thrown

When you install PowerCLI (there's just a single download)  on a 64 bit system you end up with a shortcut for "Mware vSphere PowerCLI (32-Bit)"and another for  "Mware vSphere PowerCLI".

Pavel Dimitrov Enthusiast VMware Employees 19 posts since
Oct 17, 2008
Currently Being Moderated
9. Feb 22, 2011 8:18 AM in response to: crosen
Re: Exception of type 'System.outOfMemoryException' was thrown

Could you provide some more info: Is the  script crashing always on the same line, or you're getting System.OutOfMemoryException on random  places in the code?

 

Thanks

Pavel Dimitrov Enthusiast VMware Employees 19 posts since
Oct 17, 2008
Currently Being Moderated
11. Feb 22, 2011 8:45 AM in response to: crosen
Re: Exception of type 'System.outOfMemoryException' was thrown

From the error that you pasted, I see that the script is crashed on "$vms = Get-View -ViewType VirtualMachine" which seems to be on line 17 in your code:

 

Get-View : 2/21/2011 4:12:48 PM    Get-View        Exception of type  'System.Ou
tOfMemoryException' was thrown.
At  C:\MyDocs\work\Virtualization\VMWare\VMware_Healthcheck\Notes_Fields\TCOMDB_
Data\005c_snapshot-size-vcell03.ps1:17 char:16
+ $vms = Get-View <<<<  -ViewType VirtualMachine
     + CategoryInfo          : NotSpecified: (:) [Get-View], VimException
     + FullyQualifiedErrorId :  Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
    n.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView

 

If you're saying that the script hasn't consumed all your memory and the error message is always the same, I suspect that there may be a problem with the Get-View cmdlet. I'll try to reporoduce this error, will let you know if found something.

Pavel Dimitrov Enthusiast VMware Employees 19 posts since
Oct 17, 2008
Currently Being Moderated
12. Feb 23, 2011 12:29 AM in response to: Pavel Dimitrov
Re: Exception of type 'System.outOfMemoryException' was thrown

Try to replace in the script the line:

     $vms = Get-View -ViewType VirtualMachine

with:

     $vms = Get-View -ViewType VirtualMachine -Property "LayoutEx", "Snapshot", "Config.Hardware.Device", "Name"

 

This will decrease the size of the retreived information significantly.

If it continues to crash, the reason is that on 32 bit windows the size of the heap is limited to 1.5 GB and if you still want to use this script on your environment try with 64 bit windows.

Bookmarked By (0)

Share This Page

Communities