I've heard of problems with SQL commands on machines with 1 gig or more of memory. Here's a quote from the white paper I did for my GLGDW 2002 presentation:
"Not enough memory for file map" (1150)
This error may actually be the result of too much memory! It seems to crop up on systems with 1 gig of memory or more. The way to solve this is to direct VFP on how much memory to allocate with the SYS(3050) function. Steve Dingle was having problems with this error, and has come up with a formula for setting SYS(3050).
Code:
#DEFINE diMEM_MAX_FOREGRD 256 && The max memory to allocate
#DEFINE diMEM_FOREGRD_PRECENT .90 && Percent of memory to allocate
LOCAL liNewMemory,;
liAvailableMemory
m.liAvailableMemory = ( VAL( SYS(1001) ) / 4 ) / (1024^2)
m.liNewMemory = INT( m.liAvailableMemory * diMEM_FOREGRD_PRECENT )
IF m.liNewMemory > diMEM_MAX_FOREGRD
m.liNewMemory = diMEM_MAX_FOREGRD
ENDIF
m.liNewMemory = m.liNewMemory * (1024^2)
=SYS(3050, 1, m.liNewMemory ) && Set foreground memory
=SYS(3050, 2, m.liNewMemory ) && Set background memory
This code allocates 90% of memory to foreground and background buffer memory. You may want to play around with this number. You shouldn’t need to increase the maximum above 256 megs. You also probably want to make these values configurable instead of hard coding them. Then, if they need tweaking, you don’t have to change your code. Steve also notes that playing with SYS(3050) can affect your app in a negative way so you should store an “Override” option somewhere, like in an INI file. Then, check the INI file (or whatever) first for a value and if appropriate, use the formula.
There are some additional observations from Christof Lange that help to explain things further:
1. You can’t really find the optimum setting for SYS(3050) because it will vary with the amount of physical memory available. That changes depending on what else the machine is running. If SYS(3050) is too low, it’s possible that VFP will start creating TMP files on disk, even though there’s plenty of memory available. If you set it too high, Windows will use paged memory, which results in a lot of disk swapping. If your TMP files are stored on a different disk from the one Windows uses for page swapping, you’re better off to err on the side of using the faster disk.
2. Any memory you load into the cache must be unloaded. Although unloading is faster than loading, it still takes time. The cache is unloaded when you deactivate the VFP application and the background cache is significantly smaller than the foreground cache.
3. There's an upper limit for SYS(3050) which is most noticeable with 1 GB or more of RAM. This problem is probably caused by the automatic determination of the buffer size. It seems that SYS(3050) is doing a file mapping which requires non-fragmented virtual memory and is limited to 2 GB for all file mappings in a process. If memory is already fragmented and/or more memory is allocated for other means, Windows might not have enough memory to create a file mapping of the calculated size or it takes away all space for further file mappings.
If you have a process that you know requires a lot of memory, you may want to do some garbage collection at that point. Executing SYS(1104) - which performs a garbage collection - does take some time. Hence, you shouldn't call it much more than necessary. Typically, you would place it before or after operations that require lots of memory like SELECT statements or batch updates.
-BP