標籤:lvm flow except 1.7 track maps pre 錯誤 ror
近期。使用Powershell指令碼在A7 (8核,56G記憶體)配置的 Azure VM(Virtual Machine。虛擬機器)上遠程運行Java JVM時 (java.exe -version)。總是失敗並返回例如以下的錯誤資訊。
相同的Powershell指令碼。在其他低於A7配置的VM上遠程運行一切正常;此外,假設使用遠端桌面登入到VM上,再進行相同的操作,一切運行正常。
Error occurred during initialization of VMUnable to allocate 458752KB bitmaps for parallel garbage collection for the requested 14680064KB heap.Error occurred during initialization of VMCould not reserve enough space for object heap
以上的實驗排除了是JVM(1.7)本身的問題。 看來問題非常有可能是出在Powershell的遠程運行方式上。
Powershell Remoting依賴於WinRM (Windows Remote Management)在遠程機器上運行操作。預設情況下,WinRM為每一個Powershell遠端連線分配了最大(MaxMemoryPerShellMB=1024)1G的記憶體空間(早期的版本號碼僅僅有150M),用於運行遠程操作。
但遠程操作所需的運行記憶體空間 > 1G時,就會出現了記憶體不足的問題,不同的操作可能表現會有所不同,如:有的會拋出OutOfMemoryException等。針對這個問題。解決的辦法就是添加MaxMemoryPerShellMB,然後重新啟動WinRM服務:
$maxMemoryPerShellVM = 3072Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB $maxMemoryPerShellVMSet-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB $maxMemoryPerShellVMWrite-Output "List MaxMemoryPerShellMB configuration"Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB Get-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB # Restart WinRM service to make the change take effectRestart-Service winrm
詳細要添加到多大的記憶體,須要自己去實驗一下。
參考資源
http://blog.patricknielsen.net/2012/01/powershell-remote-system-call-using.html
http://stackoverflow.com/questions/4741676/powershell-problem-running-java-remotely
Powershell遠程在Azure A7虛擬機器執行Java JVM失敗