共用方式為


Configuring the Operating Environment

An effective way to optimize Visual FoxPro performance is to get the best use of your computer's hardware and environment. This section addresses how to use memory effectively and how to get the best performance from your hard disk.

Using Memory and Virtual Memory Effectively

The most effective way to optimize your system for Visual FoxPro is to provide it with as much memory as possible. Visual FoxPro can take advantage of enormous amounts of computer memory. As well as providing memory, you can optimize the performance of Visual FoxPro by closing all other running applications on your computer.

To get the best use of your computer's memory while running Visual FoxPro, follow these guidelines:

  • Do not run any other Windows applications while Visual FoxPro is running.
  • If you have less than 16MB of RAM, do not use a RAM drive. For more information, see Managing Temporary Files.
  • Use only those memory-resident programs needed for operation.

To increase the number of applications that you can run simultaneously, Microsoft Windows supports virtual memory by swapping segments of code (code that is the least recently used) from RAM to the hard disk in the form of a swap file. As a rule, the default settings in the Windows operating system for managing virtual memory meet the requirements of most users; these settings are recommended.

Note   The swap file does not improve Visual FoxPro performance and is not a substitute for more RAM. If you do need a swap file, make sure you create a permanent one rather than a temporary one.

Simplifying the Display

You can free memory for Visual FoxPro by simplifying the way windows and screen backgrounds are displayed.

  • To free memory for running applications, use a color or a pattern for the desktop background instead of wallpaper.
  • Use the lowest-resolution display that is practical for you; the higher resolution the display, the more memory your computer requires and the slower your graphics and user-interface elements appear. For VGA-compatible displays that use an extended mode driver, such as Video 7 or 8514, using the standard VGA driver ensures faster display performance (but lower resolution and less color support).

Managing Your Hard Drive

By managing your hard drive you can improve overall product speed. Follow these guidelines for getting the best performance from your hard disk:

  • Provide a generous amount of disk space.

    Disk input/output performance degrades significantly when a disk drive is nearly full. If your disk drive has little free space, you can increase Visual FoxPro performance by removing unnecessary data or by purchasing a larger capacity drive. The more free disk space available, the more likely it is that contiguous blocks of disk space are available. Visual FoxPro uses this space for changes and additions to database, table, index, memo, and temporary files. Increasing free disk space therefore improves the performance of any commands that change or add to your files. More disk space also decreases the time required to read those files in response to your queries.

  • Periodically use a utility to defragment your hard drive. This process increases query and update performance by reducing disk thrashing.

Optimizing Files and Directories

The way that Windows and Visual FoxPro manage files on disk can greatly affect the performance of your application. This section explains how to:

  • Manage the number of files in a directory.
  • Manage how Visual FoxPro creates temporary files.

Managing Files in Directories

As a directory becomes increasingly congested with entries, the operating system takes longer to find files. How fast your system can search its directories is a function that is not under the control of Visual FoxPro.

To correct this situation, you must reduce the number of files in your directories. To reduce the number of files in your directories and speed up file search times, try the following:

  • Use the Project Manager to avoid creating numerous generated files. Segregate your program files into separate directories.

  • When you're ready to release your application, create an application or an executable file instead of numerous individually generated files.

    This process decreases the number of files in your application's subdirectories, thereby increasing performance.

  • If you delete a large proportion of files in one directory, copy the remaining files into a new directory or optimize the directory with a defragmenting utility program.

    Deleting files from a directory does not immediately speed directory searching. When a file is deleted, the entry remains as a "hole" in the directory and is still included in directory searches.

  • Make sure directories and subdirectories contain fewer than 200 files.

Managing Temporary Files

Visual FoxPro creates temporary files for a variety of activities. For example, Visual FoxPro creates temporary files during editing, indexing, and sorting. Text editor sessions can also create a complete temporary copy of the file being edited.

By default, Visual FoxPro creates its temporary files in the same directory that Windows stores its temporary files, unless you specifically designate an alternate location. Specify an alternate location by including one or more of the EDITWORK, SORTWORK, PROGWORK, or TMPFILES statements in the Config.fpw file.

To specify the location of temporary files

  1. From the Tools menu, choose Options and then choose the File Locations tab.
  2. Enter a location for temporary files.

In most cases, you should specify one location for all Visual FoxPro temporary files. However, always make sure that the location you specify has enough space for all possible temporary files.

The directory of temporary files should contain as few files as possible. A low number of files reduces the amount of time Visual FoxPro waits for Windows to return file handles.

If you have a large amount of RAM (more than 16MB), you can consider using some of it for a RAM drive and locating temporary files on it. However, in general, the more RAM that is available, the better Visual FoxPro (and other Windows applications) run, and reserving RAM for a RAM disk can affect performance adversely. If you do want to try using a RAM disk for temporary files, you should probably not specify the RAM disk in the location for the SORTWORK statement, because temporary files created during sorting can be extremely large.

For more information on temporary files, see Optimizing Visual FoxPro in a Multiuser Environment.

See Also

Optimizing Your System | Optimizing Visual FoxPro Startup Speed | Managing Temporary Files | File Locations Tab, Options Dialog Box | Options Dialog Box