Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

MEMORY(), Sys(12), Sys(1001), Sys(1016), Sys(23), Sys(24)

These are all memory-related functions. In Visual FoxPro, only three of them return anything even remotely useful. SYS(1001) tells you the size of the virtual memory pool available to Visual FoxPro. SYS(1016) tells you how much memory is currently occupied by user-defined objects. The undocumented MEMORY(1) returns SYS(1001)/1024—that is, the virtual memory pool in KB.

Usage

nMemoryPool = SYS( 1001 )
nMemoryInUse = SYS( 1016 )
nMemoryPoolInKB = MEMORY( [ 1 ] )

Help says the number returned by SYS(1001) is about four times the physical memory of the machine. That seems about right; however, with some setups, our results were on the low side of that figure.

As for SYS(1016), we do wonder what’s considered “user-defined” since we get a result of about a third of a megabyte when we first fire up VFP 7 before we get around to defining anything. Toolbars seem to count, since releasing them can lower the result. We suspect the system memory variables are taking up space in “user memory,” too.

Example

* The first results come from VFP 6
? SYS(1001)  && Returns 266027008 on Tamar's 64-meg machine
? SYS(1016)  && Returns 272840 right after startup
             && on that machine with a fairly minimal CONFIG.FPW
? MEMORY(1)  && Returns 259792 on that machine
* These results come from VFP 7.
? SYS(1001)  && Returns 1070792704 on Tamar's 256-meg machine
? SYS(1016)  && Returns 353084 right after startup
             && on that machine with a fairly minimal CONFIG.FPW
? MEMORY(1)  && Returns 1045696 on that machine

The remaining memory functions don’t return anything useful. MEMORY(), without the undocumented parameter, always says 640 (for 640 KB), while SYS(12) gives the same result in bytes—653360. SYS(23) and SYS(24) always return 0. (In fact, MEMORY(<any integer>) returns various values, some of which are recognizable, but none of which are documented.)

See Also

Sys(1104), Sys(3050)