Allocate memory
-
- I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer
The closest thing to what you want is to use GlobalMemoryStatus[Ex]. Note that in multitasking system the available memory can (and probably will) change between the call to GlobalMemoryStatus and actual allocation - so don't count on reliability of this technique. Tomasz Sowinski -- http://www.shooltz.com
-
- I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer
There's a tool that comes with VC that can simulate this if you're wanting to test your code under the extreme conditions (which is a very good thing btw).
Todd Smith
-
- I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.) - Can you show me sample codes about that task? - Regards, Maer
Man, this question is a lot harder than it sounds. The quick answer is 2GB if you don't use AWE. GlobalMemoryStatus is a start, but there are other issues. First would be what is the total number of pages a process is allowed to allocate. Second, even if you could in theory allocate tons and tons of memory, fragmentation of the address space will limit you to the total amount of memory. Tim Smith Descartes Systems Sciences, Inc.
-
The closest thing to what you want is to use GlobalMemoryStatus[Ex]. Note that in multitasking system the available memory can (and probably will) change between the call to GlobalMemoryStatus and actual allocation - so don't count on reliability of this technique. Tomasz Sowinski -- http://www.shooltz.com
- Thanks, Sowinski pal! - Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "The information returned by the GlobalMemoryStatus function is volatile.". I am a newbie of this field. I do not know what means "volatile". Can you show me an example? - Regards, Maer
-
- Thanks, Sowinski pal! - Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "The information returned by the GlobalMemoryStatus function is volatile.". I am a newbie of this field. I do not know what means "volatile". Can you show me an example? - Regards, Maer
What 'volatile' implies is that the info returned by GlobalMemoryStatus cannot be guaranteed to be correct. You can try this by making successive calls and putting a Sleep(500) in between. You can be sure that you'll get different information. This is because by the time you get the info the memory status of the system would have changed. Nish Sonork ID 100.9786 voidmain
-
There's a tool that comes with VC that can simulate this if you're wanting to test your code under the extreme conditions (which is a very good thing btw).
Todd Smith
-
Man, this question is a lot harder than it sounds. The quick answer is 2GB if you don't use AWE. GlobalMemoryStatus is a start, but there are other issues. First would be what is the total number of pages a process is allowed to allocate. Second, even if you could in theory allocate tons and tons of memory, fragmentation of the address space will limit you to the total amount of memory. Tim Smith Descartes Systems Sciences, Inc.
-
What 'volatile' implies is that the info returned by GlobalMemoryStatus cannot be guaranteed to be correct. You can try this by making successive calls and putting a Sleep(500) in between. You can be sure that you'll get different information. This is because by the time you get the info the memory status of the system would have changed. Nish Sonork ID 100.9786 voidmain