Invalid initial heap size: -Xms512m -Xmx1024m Could not create Java Virtual Machine

很遺憾,我無法reproduce當時的錯誤,只好簡單描述一下了,sigh....

在批處理文件裡設置jvm的初始內存最大/最小值。

1)首先,判斷系統可以設置的最大內存值

Start > Run > input 'cmd' in [Run] dialog and click on 'OK'.

In command window, input the following command

java -Xmx2046m -version


set JAVA_OPTS=-server -Xms768m -Xmx768m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m





注意這裡提示說明2046m超出了系統的限制。將最大內存值減小至1640m時,查看執行結果,說明系統的最大限制為1640M.

2)在批處理文件裡設置JAVA_OPTS=-Xms516m -Xmx1024m後,執行時提示如下錯誤:

Invalid initial heap size: -Xms512m -Xmx1024m

Could not create Java Virtual Machine

根據bug_34029嘗試將最大與最小內存值分別設置在兩個變量裡,即,

set JAVA_OPTS_MAX=-Xmx1024m

set JAVA_OPTS_MIN=-Xms512m

便成功了。(在reproduce時,發現即使定義在同一變量裡似乎也是沒有問題的,原因未查)


Bug34029- Invalid initial heap size: -Xms64m -Xmx512m Could not create Java Virtual Machine
Status: RESOLVED INVALID
Product: Ant
Component: Build Process
Version: 1.5
Platform: Other other
Importance: P2 normal(vote)
TargetMilestone: ---
Assigned To: Ant Notifications List
URL:
Keywords:
Dependson:
Blocks:
Show dependencytree
Reported: 2005-03-16 08:08 UTC byRajadurai
Modified: 2008-02-22 12:18 UTC (History)
CC List: 0 users



Attachments

NoteYou need tolog inbefore you can comment on or make changes to this bug.
Description Rajadurai 2005-03-16 08:08:48 UTC
i m using jdk1.5.0_01 if i user java.exe of jdk1.5.0_01 then i m getting the 
following error  Invalid initial heap size: -Xms64m -Xmx512m Could not create 
Java Virtual Machine. But if i run java.exe in the command prompt with the same 
jvm arguments. its not giving any problem. is this the bug in ant or i m doing 
any mistake. Following the target 

	
		+---------------------------------------------------
+
		|                                                   
|
		| G E N E R A T E   C U D S F   X M L               
|
		|                                                   
|
		+---------------------------------------------------
+
		Generating actions xml for ${ant.project.name}
		
		
			
			
			
			
			
			
				
				
				
			
		
		Generated actions xml for ${ant.project.name}
	
Comment 1 Jan Mat 2005-03-16 08:12:15 UTC
 gets only ONE value - maybe with spaces.

Use two  or a .

As the manual sais ...

你可能感兴趣的:(Invalid initial heap size: -Xms512m -Xmx1024m Could not create Java Virtual Machine)