Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clearing indexes from memory
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Clearing indexes from memory
Divers
Thread ID:
00210465
Message ID:
00210465
Vues:
54
Does anyone know of a way to programatically clear cached index information from memory? I'd like to write a utility program that will allow me to test the speed of different versions of a view without having to reboot my machine between each trial.

I've tried a couple of approaches so far without luck. I first tried creating objects until I got an out of memory error but that didn't work (See my post from today in the Classes-VCX section.)

I also tried creating 1,000 string variables and loading each with 65,000 zeros. That gave confusing results--it seemed to slow both SELECTS down to the same speed. (Code included below.)

I considered turning off my virtual memory setting so Win95 does not use the hard disk to extend RAM, but Windows told me I might not be able to reboot my machine if I did that (so I chickened out).

Thanks!
*---------------------------------------------------------------------
* Program.: TESTVIEW.PRG
* Author..: Mark Bucciarelli 04/13/99
* Abstract: Try to clear indexes from memory.
* Changes.:
*---------------------------------------------------------------------

LOCAL lnStart, lnEnd, lcSelect

OPEN DATA (GETFILE("dbc"))

lcSelect = "SELECT * FROM MMWO WHERE cWoAutoId='98012507' " ;
	+ "AND cSite = '' AND cEmployee = '' INTO CURSOR TEMP NOFILTER"

ClearMemory(1000)
lnStart = SECONDS()
&lcSelect
lnEnd = SECONDS()
lnTotal2a = lnStart - lnEnd
lnStart = SECONDS()
&lcSelect
lnEnd = SECONDS()
lnTotal2b = lnStart - lnEnd
?"with clear: " + STR(lnTotal2a,8,3) + " " + STR(lnTotal2b,8,3) 

Function ClearMemory
	LPARAMETERS tnCnt
	LOCAL lcOldOnError, llDone, lnIdx, lcVariable, lnCnt
	lnCnt = iif(empty(tnCnt), 100, tnCnt)

	lcOldOnError = ON("ERROR")
	ON ERROR llDone = .T.

	* 10 Meg = 10 Meg * 1024 kBytes/Meg * 1024 Bytes/kByte 
	* = 10,485,760 Bytes.  So we need 161 strings of 65,000
	* characters to take up 10 megs of memory.

	llDone = .F.
	lnIdx = 1
	DO WHILE !llDone AND lnIdx < lnCnt
		lcVariable = "String" + LTRIM(STR(lnIdx))
		LOCAL &lcVariable
		&lcVariable = REPLICATE("00000000", 65000)
		lnIdx = lnIdx + 1
	ENDDO && !llDone
	
	ON ERROR &lcOldOnError
	RETURN lnIdx
ENDPROC
----------
Mark Bucciarelli
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform