java.lang.OutOfMemoryError 在 Heroku 中部署 war 文件时
java.lang.OutOfMemoryError while deploying the war file in Heroku
在尝试将我的 Spring MVC 应用程序 war 文件部署到 Heroku 时,出现 java.lang.OutofMemoryError 异常。此异常的原因可能是什么?我做错了什么?
C:\Users\sai\Desktop>heroku deploy:war --war crud-1.0.0-BUILD-SNAPSHOT.war --app springmvc-crud-jpa
Uploading crud-1.0.0-BUILD-SNAPSHOT.war....
---> Packaging application...
- app: springmvc-crud-jpa
- including: webapp-runner.jar
- including: crud-1.0.0-BUILD-SNAPSHOT.war
- installing: OpenJDK 1.8
---> Creating slug...
- file: slug.tgz
- size: 68MB
---> Uploading slug... Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.io.ByteArrayOutputStream.grow(Unknown Source)
at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
at java.io.ByteArrayOutputStream.write(Unknown Source)
at sun.net.www.http.PosterOutputStream.write(Unknown Source)
at com.heroku.sdk.deploy.Curl.put(Curl.java:75)
at com.heroku.sdk.deploy.Slug.upload(Slug.java:81)
at com.heroku.sdk.deploy.App.uploadSlug(App.java:196)
at com.heroku.sdk.deploy.App.deploySlug(App.java:186)
at com.heroku.sdk.deploy.App.createAndReleaseSlug(App.java:169)
at com.heroku.sdk.deploy.App.deploy(App.java:83)
at com.heroku.sdk.deploy.App.deploy(App.java:87)
at com.heroku.sdk.deploy.WarApp.deploy(WarApp.java:32)
at com.heroku.sdk.deploy.DeployWar.main(DeployWar.java:51)
---> Done
我是 heroku-deploy 插件的维护者。我已经增加了该工具的默认堆大小,因此如果您通过 运行 heroku plugins:install https://github.com/heroku/heroku-deploy
重新安装它然后再次部署,它有望正常工作。
如果其他人继续遇到此问题,您可以通过将 JAVA_TOOL_OPTIONS
环境变量设置为 -Xmx2g
.
之类的内容来进一步手动增加堆大小
在尝试将我的 Spring MVC 应用程序 war 文件部署到 Heroku 时,出现 java.lang.OutofMemoryError 异常。此异常的原因可能是什么?我做错了什么?
C:\Users\sai\Desktop>heroku deploy:war --war crud-1.0.0-BUILD-SNAPSHOT.war --app springmvc-crud-jpa
Uploading crud-1.0.0-BUILD-SNAPSHOT.war....
---> Packaging application...
- app: springmvc-crud-jpa
- including: webapp-runner.jar
- including: crud-1.0.0-BUILD-SNAPSHOT.war
- installing: OpenJDK 1.8
---> Creating slug...
- file: slug.tgz
- size: 68MB
---> Uploading slug... Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.io.ByteArrayOutputStream.grow(Unknown Source)
at java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
at java.io.ByteArrayOutputStream.write(Unknown Source)
at sun.net.www.http.PosterOutputStream.write(Unknown Source)
at com.heroku.sdk.deploy.Curl.put(Curl.java:75)
at com.heroku.sdk.deploy.Slug.upload(Slug.java:81)
at com.heroku.sdk.deploy.App.uploadSlug(App.java:196)
at com.heroku.sdk.deploy.App.deploySlug(App.java:186)
at com.heroku.sdk.deploy.App.createAndReleaseSlug(App.java:169)
at com.heroku.sdk.deploy.App.deploy(App.java:83)
at com.heroku.sdk.deploy.App.deploy(App.java:87)
at com.heroku.sdk.deploy.WarApp.deploy(WarApp.java:32)
at com.heroku.sdk.deploy.DeployWar.main(DeployWar.java:51)
---> Done
我是 heroku-deploy 插件的维护者。我已经增加了该工具的默认堆大小,因此如果您通过 运行 heroku plugins:install https://github.com/heroku/heroku-deploy
重新安装它然后再次部署,它有望正常工作。
如果其他人继续遇到此问题,您可以通过将 JAVA_TOOL_OPTIONS
环境变量设置为 -Xmx2g
.