Microsoft KB Archive/125374

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft FoxPro for Macintosh, version 2.6a

-

SYMPTOMS
Looping through a Table with a SCAN..ENDSCAN will reduce the amount of memory available to less than 200,000 bytes after a number of records have been processed. How quickly the memory is depleted depends on how many fields are in the database and on how many tables are open in addition to the table used by the loop. If the number of fields is less than five, the memory is not reduced below 200,000 bytes for a 50,000 record database.

RESOLUTION
The memory leak can be avoided by testing for low memory in the loop and calling a function to close and reopen the database. Low memory is tested for by using SYS functions SYS(1001) and SYS(1016). SYS(1001) returns the total amount of memory available to the FoxPro memory manager, and SYS(1016) returns the amount of memory being used.

STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro 3.0b for Macintosh.

Steps to Reproduce Problem
Open a database that has about 50,000 records and more than five fields. Then execute the following code:    SCAN ALL NOOPTIMIZE MEMLEFT= VAL(SYS(1001))-VAL(SYS(1016)) IF MEMLEFT< 200000 CURREC=RECNO WAIT WINDOW STR(MEMLEFT)+" "+STR(RECNO) *      DO RESTORMEM WITH CURREC ENDIF ENDSCAN

PROCEDURE RESTORMEM PARAMETER WHATRECORD DB_NAME= ALIAS USE USE (DB_NAME) MEMLEFT= VAL(SYS(1001))-VAL(SYS(1016)) WAIT WINDOW STR(MEMLEFT)+" "+ STR(RECNO) GO WHATRECORD RETURN In one test, the wait window appeared after approximately 33,000 records have been processed if no other databases are open. The preferred size for FoxPro was set at 8000k.

Removing the asterisk from the DO RESTORMEM line to change it from a comment to code. Now, the procedure will run correctly. This illustrates that memory is restored by closing and reopening the database. Approximately 33,000 records will be processed before the procedure is executed again. Additional query words: fixlist3.00b VFoxMac FoxMac buglist2.60a

Keywords         : FxotherGeneral Version          : 2.60a Platform         : MACINTOSH Issue type       :
 * }