When Matlab is used to generate a large image, an "out of memory" error occurs, causing the image to fail to be generated. Therefore, the virtual memory has to be extended. The specific process records are as follows:
1) view the current virtual memory
In the MATLAB command line, type the command: feature ('memstats') and get the following results:
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)
The Virtual Memory displayed in the result is virtual memory = 2047 MB;
2) increase the virtual memory
The following method can increase the virtual memory used for Matlab in win7 32-bit OS to 3 GB.
Set: Start --- all programs --- attachments, right-click the command prompt, and select "Run as administrator ",
Enter bcdedit/set increaseuserva 3072 and press enter to restart the computer.
Cancel: Start --- all programs --- attachments, right-click the command prompt, and select "Run as administrator ",
Enter bcdedit/deletevalue increaseuserva and press enter to restart the computer.
(Note: bcdedit is a command line tool in the nt60 Operating System (Windows 7/Vista/2008). It is used to create and reconfigure bootloader. The above command allows the user's program to use a maximum of 3G memory, while win7 32 can recognize 3G, so trying to change 3072 to a larger value in a 32-bit system is futile !)
3) view results
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) ans = 1.0733e+09
The results show that the virtual memory is increased to 3071 MB and the program is re-run successfully!
4) extended thinking
We continue to increase the image size and find that there will still be insufficient memory. It seems that the above method is not a cure, and we can only consider whether the program itself has a design problem!
Reference: http://www.cnblogs.com/bovine/archive/2011/10/11/2206876.html