- 首先,我认为 java 命令行的顺序很重要,因此 -Xmx 选项应该位于“java”之后和“-jar”标记之前。
- 接下来,我想知道您是否尝试使用过多的内存。您是否考虑过使用较小的值对此进行测试?
例如:
$Combo1 = GUICtrlCreateCombo("Java Memory", 10, 10, 142, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "-Xmx100M|-Xmx200M|-Xmx400M|-Xmx800M|-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M")
然后看看是否有任何较小的数字有效,以及较大的数字是否会破坏程序。
我的测试程序:
AutoIt 程序,MyFoo.au3:
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $msg
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
$Combo1 = GUICtrlCreateCombo("Java Memory", 10, 10, 142, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "-Xmx100M|-Xmx200M|-Xmx400M|-Xmx800M|-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M")
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $Combo1 Then
$chosen = GUICtrlRead($Combo1)
$runString1 = "java " & $chosen & " -jar MyFoo.jar"
$runString2 = "java -jar MyFoo.jar " & $chosen
ConsoleWrite($runString1 & @CRLF)
Run($runString1)
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc
Java 测试程序,MyAutoItFoo.java。当然,这首先是 jar'd:
import javax.swing.JOptionPane;
public class MyAutoItFoo {
public static void main(String[] args) {
long heapSize = Runtime.getRuntime().totalMemory();
long heapMaxSize = Runtime.getRuntime().maxMemory();
String heapString = String.format("Heap Size = %H; Max Heap = %H",
heapSize, heapMaxSize);
System.out.println(heapString);
JOptionPane.showMessageDialog(null, heapString);
}
}