matlab擴大虛擬記憶體
阿新 • • 發佈:2018-12-30
deeplearning toolbox的example跑minist手寫字型檔出現爆記憶體的錯誤,找到一個擴大虛擬記憶體的方法。
使用Matlab生成很大的圖片時,碰到了"out of memory"的錯誤,導致圖片無法生成,於是不得不擴充套件虛擬記憶體。具體過程記錄如下:
1)檢視當前的虛擬記憶體
在Matlab的命令列中,鍵入命令:feature ('memstats'),得到如下結果:
- Physical Memory (RAM):
- In Use: 1499 MB (5dba0000)
- Free: 1571 MB (6237e000)
- Total: 3071 MB (bff1e000)
- Page File (Swap space):
- In Use: 1694 MB (69e67000)
- Free: 4446 MB (115e1e000)
- Total: 6140 MB (17fc85000)
- Virtual Memory (Address Space):
- In Use: 633 MB (279fe000)
- Free: 1413 MB (585e2000)
- Total: 2047 MB (7ffe0000)
- Largest Contiguous Free Blocks:
- 1. [at 22cb0000] 1239 MB (4d750000)
- 2. [at 7da16000] 28 MB ( 1cda000)
- 3. [at 70856000] 17 MB ( 112a000)
- 4. [at 77281000] 16 MB ( 107f000)
- 5. [at 7f7f0000] 6 MB ( 68f000)
- 6. [at 7ae71000] 6 MB ( 60f000)
- 7. [at 7cd15000] 5 MB ( 5eb000)
- 8. [at 7409e000] 5 MB ( 5d2000)
- 9. [at 72b63000] 5 MB ( 53d000)
- 10. [at 71ab3000] 4 MB ( 4fd000)
- ======= ==========
- 1336 MB (53868000)
- class="line number29 index28 alt2"> </div>
結果中顯示的虛擬記憶體為Virtual Memory=2047MB;
2)增加虛擬記憶體
下面方法可使win7 32位OS下用於matlab的虛擬記憶體增加到3G。
設定: 開始---所有程式---附件,右擊命令提示符,選擇“以管理員身份執行”,
輸入:bcdedit /set IncreaseUserVa 3072 回車,重啟電腦。
取消: 開始---所有程式---附件,右擊命令提示符,選擇“以管理員身份執行”,
輸入:bcdedit /deletevalue IncreaseUserVa 回車,重啟電腦。
( 注:bcdedit是NT60系列作業系統(Windows 7/Vista/2008)中的一個命令列工具,用於建立和重新配置bootloader。上面命令作用允許使用者的程式使用最大3G記憶體,而win7 32能識別的就是3G,所以,試圖將3072改成更大值在32位系統中是徒勞的!)
3)檢視結果
- Physical Memory (RAM):
- In Use: 1355 MB (54be5000)
- Free: 1661 MB (67df7000)
- Total: 3017 MB (bc9dc000)
- Page File (Swap space):
- In Use: 2931 MB (b73af000)
- Free: 3126 MB (c3650000)
- Total: 6057 MB (17a9ff000)
- Virtual Memory (Address Space):
- In Use: 755 MB (2f36c000)
- Free: 2316 MB (90c74000)
- Total: 3071 MB (bffe0000)
- Largest Contiguous Free Blocks:
- 1. [at 7fff0000] 1023 MB (3ff8a000)
- 2. [at 2bcb0000] 579 MB (24340000)
- 3. [at 50000000] 428 MB (1ac00000)
- 4. [at 6ac16000] 83 MB ( 53ea000)
- 5. [at 284f0000] 47 MB ( 2fc0000)
- 6. [at 77ce1000] 22 MB ( 167f000)
- 7. [at 7c43b000] 14 MB ( ea5000)
- 8. [at 7f7f0000] 7 MB ( 7f0000)
- 9. [at 711bb000] 6 MB ( 665000)
- 10. [at 7be74000] 5 MB ( 51c000)
- ======= ==========
- 2219 MB (8ab09000)
- ns =
- 1.0733e+09
從結果可以看出,虛擬記憶體提高到了3071MB,重新執行程式,成功!
