近期。使用Powershell脚本在A7 (8核,56G内存)配置的 Azure VM(Virtual Machine。虚拟机)上远程运行Java JVM时 (java.exe -version)。总是失败并返回例如以下的错误信息。

相同的Powershell脚本。在其他低于A7配置的VM上远程运行一切正常;此外,假设使用远程桌面登录到VM上,再进行相同的操作,一切运行正常。

Error occurred during initialization of VM
Unable to allocate 458752KB bitmaps for parallel garbage collection for the requested 14680064KB heap. Error occurred during initialization of VM
Could 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 = 3072
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB $maxMemoryPerShellVM
Set-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB $maxMemoryPerShellVM Write-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 effect
Restart-Service winrm

详细要添加到多大的内存,须要自己去实验一下。

參考资源

http://blog.patricknielsen.net/2012/01/powershell-remote-system-call-using.html

http://stackoverflow.com/questions/4741676/powershell-problem-running-java-remotely






最新文章

  1. oracle 存储过程的用法
  2. mybatis一个怪异的问题: Invalid bound statement not found
  3. Redis总结(五)缓存雪崩和缓存穿透等问题
  4. (转载)HTML标签<br><br/>的区别在哪里?
  5. 关键字explicit
  6. 搬瓦工搭建SS的教程
  7. MinerQueue.java 访问队列
  8. nginx反向代理配置
  9. 基于VUE框架 与 其他框架间的基本对比
  10. bzoj 2599
  11. springboot 启动报错
  12. poj 1050 最大子矩阵
  13. css 禁止选中文本
  14. Neo4j学习案例【转】
  15. 20190118_xlVBA多表合并
  16. GDB 调试 ---转 比较全的东东
  17. Docker概念学习系列之Docker核心概念之仓库Repository
  18. 为什么使用消息队列,为什么使用RabbitMQ、springAMQP
  19. MongoDB入门必读(概念与实战并重)
  20. Ubuntu远程桌面,如何退出全屏

热门文章

  1. NX自动出图 发布啦
  2. HDU_3591_(多重背包+完全背包)
  3. Vue指令4:v-on
  4. JavaScipt30(第七个案例)(主要知识点:数组some,every,findIndex方法)
  5. xmpp 消息和好友上下线(3)
  6. datatable 分组
  7. LeetCode15——3Sum
  8. P4817 [USACO15DEC]Fruit Feast 水果盛宴
  9. 常用Linux命令_20190211
  10. 阿里云创建CentOS系统设置