View Full Version : How to find contiguous memory available?

12-17-2008, 01:28 PM
I couldn't find the answer to this in the other posts, so maybe I'm the first to ask. How in PV-WAVE can I find the maximum contiguous memory available? I need a way to determine if an array allocation is going to error due to insufficient memory. I want to trap this error, for example:

WAVE> a = fltarr(2e9)
%%%Unable to allocate memory: to make array.
%%%Execution halted at $MAIN$ (FLTARR).

You can uses the MEMORY keyword in a INFO call, but this doesn't tell you how much memory is left:

WAVE> info, /mem
heap memory in use: 3160692, calls to MALLOC: 144289, FREE: 135761
WAVE> a = fltarr(200)
WAVE> info, /mem
heap memory in use: 3161627, calls to MALLOC: 144292, FREE: 135761

Is there any WAVE function that returns the available memory, or max allowable array size? Is there a DOS command that could be called and parse? Can I trap the error in any other way, like using ON_ERROR_GOTO?

12-19-2008, 04:12 PM
Hi hcrisp,
I'm not sure if this is an answer or not. I would have thought that if the mem command didn't answer it then maybe there wasn't an answer... it seems to report contiguous memory, but it reports 0 bytes available on my machine... that certainly looks suspicious. What does your system report?

C:\Documents and Settings\rwagner\Desktop>mem

655360 bytes total conventional memory
655360 bytes available to MS-DOS
627392 largest executable program size

1048576 bytes total contiguous extended memory
0 bytes available contiguous extended memory
941056 bytes available XMS memory
MS-DOS resident in High Memory Area

12-19-2008, 04:42 PM
Well, "mem" was useful back in the old DOS days, but on a Windows machine nowadays it will only report on memory available to the current shell session. This can be affected by the shortcut used to start it, so it's really not indicative of anything system-wide.

"winmsd" is probably the most accurate info available on an XP machine, but still doesn't talk about contiguous memory.