Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insufficient memory with VFP 6.0 app 1

Status
Not open for further replies.

crossface

Programmer
Nov 30, 2002
81
US
I have a mature application with over a 1000 users. I have had a couple of users who indicate that they get an error "insufficient memory" when running the exe.

This app runs on all machines Win 95 or higher

What could cause this?

They have new Dell machines with lots of memory.

Could they have too much memory?

I heard that this was a problem with with VFP 3.0 compiled apps but not 6.0 Recompiling in 7.0 or 8.0 is not an option at this time.

Is there a way to control how much memory is available to an application.

Kevin Cotter
 
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
 
Crossface,

Put this command in the config.sys,

files = 255
buffers = 80

Save the file and reboot your pc. Rerun again your apps.

Hope this may help.


Bren
VFP - Philippines
 
Bren,
Unfortunately this doesn't apply to NT/2000/XP machines, and it rarely makes any difference in "Insufficient memory" problems.

Rick
 
Rick,

Yes Rick you're right as this applies to Win 9x only. I assumed this problem applies to 9x versions as crossface mentioned some machines are using Win 9x. However, the buffers I've mentioned earlier will actually give enough buffer space for the active windows.


Bren
VFP - PHilippines
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top