VMware Cloud Community
vijaysaiv
Contributor
Contributor

Powercli 6.5 memory leak

Folks,

I am new to power cli, and started using it from couple of months. I was very happy with PowerCLI 6.3 but I recently upgraded to PowerCLI 6.5 (Powershell 4.0 or 5.0) as our vcenter is upgraded to 6.5.

The moment I upgraded, I started running into memory issues.

Each end every command of powercli leaks memory and not freed for ever until I force garbage collect.

Connect-VIserver, get-vm etc, all commands are leaking memory big time. Have you seen this kind of issue any time? is there anyway we can contain this leak.

Here is my envivonment: Windows 2012 R2 server, .net 4.0, PowerShell 4.0/5.0, PowerCLI 6.5, Vcenter 6.5.

Appreciate your help.

Regards

Vijay

27 Replies
vijaysaiv
Contributor
Contributor

Thank you.

I will try to open a SR. However, can you tell me what would be the difference between PowerCLI 6.0 and PowerCLI 6.5.x? And why the same code behaves differently? Please note that we are calling these scripts from .Net. The same .Net application binary works well with Power CLI 6.0 but not with PowerCLI 6.5. The .net code or the scripts are not changed.

0 Kudos
vijaysaiv
Contributor
Contributor

Here is the DCPN case # 00046585.

We see that the problem is same through all versions of 6.5. We also have provided memory logs.

ricardo_sanchez
Contributor
Contributor

Did you guys ever got to the bottom of this issue? One of our scripts starts off by consuming about 150 MB and gradually increases over time until it reaches 4 GB of ram consumed. I am attaching the output of Get-Module in case it helps. The script itself iterates through a list of VMs calling Get-VM in a for loop to then generate a CSV with a bunch of attributes (IP address, Name, OS, etc.) Pretty standard stuff. The number of VMs is not even 10K.

ModuleType Version    Name                                ExportedCommands

---------- -------    ----                                ----------------

Script     0.0        Initialize-VMware.VimAutomation....

Script     0.0        Initialize-VMware_DeployAutomation

Script     0.0        Initialize-VMware_VimAutomation_Cis

Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...

Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}

Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...

Binary     6.0.0.0    VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-D...

Binary     6.0.0.0    VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-Esx...

Binary     6.5.0.4... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}

Manifest   6.5.0.4... VMware.VimAutomation.Common

Binary     6.5.0.2... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...

Binary     6.0.0.0    VMware.VimAutomation.HA             Get-DrmInfo

Binary     6.5.0.4... VMware.VimAutomation.License        Get-LicenseDataManager

Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion

Binary     6.5.0.4... VMware.VimAutomation.Storage        {Copy-VDisk, Export-SpbmStoragePolicy, Get-NfsUser, Get-Sp...

Binary     6.5.0.4... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, E..

0 Kudos
vijaysaiv
Contributor
Contributor

ricardo_sanchez​,

Yes. We implemented similar script to identify the issue and it is indeed a memory leak issue in PowerCLI.

The issue has been fixed in PowerCLI 10.0 and above. You may want to give a try by upgrading to latest version of PowerCLI.

0 Kudos
ricardo_sanchez
Contributor
Contributor

vijaysaiv​ Thank you for your reply; it is tremendously helpful. I will upgrade to PowerCLI 10 and give it another try.

0 Kudos
vijaysaiv
Contributor
Contributor

ricardo_sanchez

Were you able to upgrade to powercli 10.0 ?

0 Kudos
ricardo_sanchez
Contributor
Contributor

Yes, vijaysaiv​, thanks again for the tip! I actually upgraded to PowerCli 11.2 but to be honest, I still think there's something incredibly wrong with their implementation - extracting data for a couple hundred VMs takes as much as 900 MB of RAM. In any case, I am good for the time being.

0 Kudos
vijaysaiv
Contributor
Contributor

Good. But we didn't observe the same on 10.0.

0 Kudos