问题描述
我有一个申请.我通过
gradlew run-app
或调试
gradlew debug-app
有效.如何将"-Xmx"参数传递给我运行的应用程序(调试)?是否可以在不编辑build.gradle
文件的情况下这样做?
It works. How do I pass '-Xmx' argument into the application which I run (debug)?Is it possible to do so without edditing build.gradle
file?
我发现了这个为未知的命令行选项'-X'分级
尝试时会收到类似的错误
I get a similar error when I try
gradlew debug-app -Xmx2000m
错误
FAILURE: Build failed with an exception.
* What went wrong:
Problem configuring task :debug-app from command line.
> Unknown command-line option '-X'.
我试图在GRADLE_USER_HOME
目录中创建文件gradle.properties
(默认情况下为USER_HOME/.gradle).
I tried to create a file gradle.properties
in GRADLE_USER_HOME
directory (by default, it is USER_HOME/.gradle).
org.gradle.jvmargs=-XX\:MaxHeapSize\=4256m -Xmx4256m -Xms2000m
我也试图在项目文件夹gradle.properties
中的org.gradle.jvmargs=-Xmx2000m
.
I also tried to org.gradle.jvmargs=-Xmx2000m
in project folder gradle.properties
.
即使在我运行应用程序时,我也会看到Committed Memory大小为<. 520 MiB
And even then when I run an application, I see Commited Memory size is < 520 MiB
这是我作为普通Java应用程序运行时的情况
And this is when I run it as a normal Java App
在第二种情况下,当我使用-Xms,-Xmx作为普通Java应用程序运行该应用程序时,由于我传递了-Xmx4512m -Xms2512m
参数,因此Committed Memory大小约为3.5 GiB.
In the second case, when I run the application as a normal Java app with -Xms, -Xmx, Commited Memory size is about 3.5 GiB because I passed -Xmx4512m -Xms2512m
parameters.
推荐答案
将此添加到您的gradle.properties
文件中:
Add this in your gradle.properties
file :
org.gradle.jvmargs=-Xmx2000m
从此处
指定用于守护进程的jvmargs.设置是 在调整内存设置时特别有用.此刻 默认设置在内存方面非常慷慨.
Specifies the jvmargs used for the daemon process. The setting is particularly useful for tweaking memory settings. At the moment the default settings are pretty generous with regards to memory.
edit:我的回答是关于gradle守护进程jvm,而不是应用程序jvm.您必须使用 jvmArgs属性
edit : my answer what about the gradle daemon jvm, not the app jvm. You have to use the jvmArgs property
这篇关于通过gradlew使用-Xmx和-Xms运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!