Monday, February 15, 2016

Reduce Memory usage in Visual Foxpro

Routine to be called to limit Visual FoxPro to using only physical RAM, not virtual memory. Can vastly improve performance, especially when running queries. Author: Ed Leafe Freeware 1K Last updated: 2000.01.20
 
LOCAL lnAvailableMem, lpMemoryStatus, lnPct  

* Running on the desktop 
DECLARE GlobalMemoryStatus IN Win32API STRING @lpMemoryStatus 
lpMemoryStatus = REPLICATE(CHR(0), 32) 
GlobalMemoryStatus(@lpMemoryStatus)  
lnAvailableMem = CharToBin(SUBSTR(lpMemoryStatus, 13, 4))  

*** EGL: 11/30/98 - Added the fine tuning option 
lnPct = 1 

IF TYPE("goApp.nSetMemoryPct") == "N" 
     lnPct = goApp.nSetMemoryPct 
ENDIF 

lnAvailableMem = (lnAvailableMem * lnPct)  
SYS(3050, 1, lnAvailableMem) 
SYS(3050, 2, (lnAvailableMem/2) )  
RETURN lnAvailableMem   

*************************** 
FUNCTION CharToBin (tcWord) 
***************************  
LOCAL lnChar, lnWord  lnWord = 0  
FOR lnChar = 1 TO LEN(tcWord)   
    lnWord = lnWord + (ASC(SUBSTR(tcWord, lnChar, 1)) * (2 ^ (8 * (lnChar - 1))))  
ENDFOR   
RETURN lnWord ENDFUNC  
}





No comments:

Post a Comment