Android的摇篮:什么是javaMaxHeapSize"4克"? [英] Android Gradle: What is javaMaxHeapSize "4g"?
问题描述
在一个Android项目, 的build.gradle 的文件,我已经通过此行
In an android project, build.gradle file, I have been through this line
dexOptions{
javaMaxHeapSize "4g"
}
我想知道确切的目的,此 javaMaxHeapSize 并又有什么4克表示。什么是其他值我可以给?
I would like to know the exact purpose of this javaMaxHeapSize and what does that 4g means. What are other values I can give ?
推荐答案
由于它在回答上面提到的,只是,以指定的最大存储器分配池用于塞米松动作的Java虚拟机(JVM)的选项。而且它是相同的,以提供对Java的 -Xmx
参数。由于它的源$ C $ CS由<一个href=\"https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/DexOptionsImpl.groovy\">here,它的制定者的样子:
As it mentioned in the answer above, it is just an option to specify the maximum memory allocation pool for a Java Virtual Machine (JVM) for dex operation. And it's the same, as to provide to java the -xmx
argument. Due to it's source codes from here, it's setter look like:
if (theJavaMaxHeapSize.matches("\\d+[kKmMgGtT]?")) {
javaMaxHeapSize = theJavaMaxHeapSize
} else {
throw new IllegalArgumentException(
"Invalid max heap size DexOption. See `man java` for valid -Xmx arguments.")
}
所以,你可以看到,所接受的值应该匹配 \\ D + kKmMgGtT]
模式,因此没有,甚至指男人的java
结识,如何设置 -Xmx
。您可以阅读 href=\"http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/java.html\">手册页。它说,这标志:
So, you can see, that the accepted value should match the \d+[kKmMgGtT]?
pattern, and hence not, it even refers to the man java
to get to know, how to set the -xmx
. You can read the man page here. And it says, that this flag:
指定的最大大小,以字节为单位的内存分配池。该值必须是1024的倍数大于2MB。追加字母k或K来表示千字节,m或M来表示兆字节。默认值是根据系统配置选择在运行时。
Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration.
在你的榜样,4克
4 GB的,这是DEX操作的最大堆大小。
In your example, 4g
is 4 Gigabytes and this is a maximum heap size for dex operation.
这篇关于Android的摇篮:什么是javaMaxHeapSize&QUOT;4克&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!