Fellows,
I need to find the total size of physical RAM on the box programmatically (for speed optimization).
"Wintage" (
) functions like SYS(12) or SYS(1001) ain't no help at all.
Function SYS(3050) is not of much help either: it gives you approx 65% of total RAM for the foreground run, and approx. 16% for the background run. Those are default VFP (or WinOS?) settings (well, at least on my machine, anyway).
However, according to the article "Set Turbo On: How Visual FoxPro Memory Usage Affects Performance" by Flavio Almeida and Walter Loughney (FoxTalk, Feb. 1997 issue), the best performance was achieved when the (foreground) buffer memory size is set to approx. 45%-50% of total physical RAM.
But I have to first find out that physical RAM size, don't I? I could have just
but that would be kinda "malpractice", wouldn't it?
There's also WinAPI function:
BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
The problem is that LPMEMORYSTATUSEX is a structure, that is defined in C as
typedef struct _MEMORYSTATUSEX {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORDLONG ullTotalPhys;
DWORDLONG ullAvailPhys;
DWORDLONG ullTotalPageFile;
DWORDLONG ullAvailPageFile;
DWORDLONG ullTotalVirtual;
DWORDLONG ullAvailVirtual;
DWORDLONG ullAvailExtendedVirtual;
} MEMORYSTATUSEX
As far as I know, there's no structure data type in Fox.
Besides, when I tried to DECLARE and test this function off the Command window in VFP (7.0 SP1, to be exact), like
DECLARE INTEGER GlobalMemoryStatusEx IN Kernel32.dll @lpBuffer
DECLARE scrArr(9)
scrArr[1]=32*9
scrArr[2]=0
scrArr[3]=0
scrArr[4]=0
scrArr[5]=0
scrArr[6]=0
scrArr[7]=0
scrArr[8]=0
scrArr[9]=0
?GlobalMemoryStatusEx(@scrArr)
it gave me that notorious error message:
"Cannot find entry point GlobalMemoryStatusEx in the DLL"![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
Is there any way around?
Bottom line: how do I find the size of RAM on the box programmatically?
AHWBGA
Regards,
Ilya
I need to find the total size of physical RAM on the box programmatically (for speed optimization).
"Wintage" (
![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
Function SYS(3050) is not of much help either: it gives you approx 65% of total RAM for the foreground run, and approx. 16% for the background run. Those are default VFP (or WinOS?) settings (well, at least on my machine, anyway).
However, according to the article "Set Turbo On: How Visual FoxPro Memory Usage Affects Performance" by Flavio Almeida and Walter Loughney (FoxTalk, Feb. 1997 issue), the best performance was achieved when the (foreground) buffer memory size is set to approx. 45%-50% of total physical RAM.
But I have to first find out that physical RAM size, don't I? I could have just
Code:
lnTotalRAM = VAL(SYS(3050, 1))/.65
but that would be kinda "malpractice", wouldn't it?
There's also WinAPI function:
BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
The problem is that LPMEMORYSTATUSEX is a structure, that is defined in C as
typedef struct _MEMORYSTATUSEX {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORDLONG ullTotalPhys;
DWORDLONG ullAvailPhys;
DWORDLONG ullTotalPageFile;
DWORDLONG ullAvailPageFile;
DWORDLONG ullTotalVirtual;
DWORDLONG ullAvailVirtual;
DWORDLONG ullAvailExtendedVirtual;
} MEMORYSTATUSEX
As far as I know, there's no structure data type in Fox.
Besides, when I tried to DECLARE and test this function off the Command window in VFP (7.0 SP1, to be exact), like
DECLARE INTEGER GlobalMemoryStatusEx IN Kernel32.dll @lpBuffer
DECLARE scrArr(9)
scrArr[1]=32*9
scrArr[2]=0
scrArr[3]=0
scrArr[4]=0
scrArr[5]=0
scrArr[6]=0
scrArr[7]=0
scrArr[8]=0
scrArr[9]=0
?GlobalMemoryStatusEx(@scrArr)
it gave me that notorious error message:
"Cannot find entry point GlobalMemoryStatusEx in the DLL"
![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
Is there any way around?
Bottom line: how do I find the size of RAM on the box programmatically?
AHWBGA
Regards,
Ilya