VirtualBox可不像VMware那樣,直接複製虛擬磁盤文件就可以了事的,只因為VirtualBox識別虛擬磁盤文件VDI採用了uuid識別技術.
由於測試需要搭建局域網環境,需要兩台虛擬機同時運行。當我安裝完一個虛擬系統時,我將虛擬磁盤文件複製一份重新創建虛擬系統時提示打開 虛擬硬盤 5.04.vdi 失敗.
Cannot register the hard disk '5.04.vdi' with UUID {24eb969f-8c98-470d-b2dd-35318f2b8860} because a hard disk '5.04.vdi' with UUID {24eb969f-8c98-470d-b2dd-35318f2b8860} already exists in the media registry ('C:\Documents and Settings\Blinux\.VirtualBox\VirtualBox.xml').
解法:
使用VirtualBox,新增機器
選擇"使用現有硬碟"=>在複製到硬碟的vdi目錄找到"Snapshots"資料夾,選擇裡面的Vdi檔
檔名類似這樣=>{c5575453-83cb-47f9-bebd-e37e20f82458}.vdi,即完成設定
2011年6月17日 星期五
2011年6月8日 星期三
Java 程式Memory使用量
Java VM內存堆疊的記憶體使用量
現在使用量: Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()
由兩次使用量計算出中間使用了多少記憶體
現在使用量: Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()
由兩次使用量計算出中間使用了多少記憶體
public class MemoryTester {
public static void main(String[] args) {
System.out.println("max memory:"
+ Runtime.getRuntime().maxMemory()
+ " bytes");
System.out.println("total memory:"
+ Runtime.getRuntime().totalMemory()
+ " bytes");
System.out.println("free memory:"
+ Runtime.getRuntime().freeMemory()
+ " bytes");
long memory = Runtime.getRuntime().totalMemory()
- Runtime.getRuntime().freeMemory();
ArrayList list = new ArrayList();
for (int i = 0; i < 10000; i++)
list.add(i);
System.out.println("max memory:"
+ Runtime.getRuntime().maxMemory()
+ " bytes");
System.out.println("total memory:"
+ Runtime.getRuntime().totalMemory()
+ " bytes");
System.out.println("free memory:"
+ Runtime.getRuntime().freeMemory()
+ " bytes");
memory = Runtime.getRuntime().totalMemory()
- Runtime.getRuntime().freeMemory() - memory;
System.out.println(memory + " bytes");
}
}
訂閱:
意見 (Atom)