Image of Navigational Map linked to Home / Contents / Search Problem with MS Share Lock-Count

Rafael Merino - GUI Computing
Image of Line Break

The Problem

Your program keeps falling over during file i/o operation for no apparent reason, and the following message keeps appearing:

"MS-DOS File sharing lock-count exceeded. You need to increase the number of locks with share.exe".

First, remain calm. This is usually not to hard to fix.

The Cause

During normal i/o processing data is locked and unlocked behind the scenes. However, during intensive data processing operations the normal background management of locking is unable to keep up, resulting in a buildup of locks.

If you are using the DOS file sharing, mechanism SHARE.EXE, then it means that you have reached the upper limit of the settings for file sharing. There are a number of strategies you can use to overcome this. If you are using the Windows Virtual Sharing mechanism, VSHARE.386, then you will not have this problem. However you may run out of virtual memory, in which case you need to use your Control Panel to increase it, or buy more RAM, or multi-task fewer programs.

The Solution

The Strategies you can use to overcome this are listed below :

  1. Stop using the DOS file sharing, and install the Windows Virtual Share driver. To do this simply REM out any references to SHARE.EXE in your AUTOEXEC.BAT file. Then copy the VSHARE.386 file from your Windows disks into the Windows System directory (unless it is already there), and add the following line to the SYSTEM.INI file in the 386 Enhanced section.
    "device=vshare.386".

    Note : Applications that run in DOS may require the SHARE.EXE, although they are becoming rare these days, in which case the above strategy is NOT recommended.

  2. Use the FreeLocks command regularly in your code, particularly after using the Execute and Close methods. This strategy is recommended whether you are using the DOS or Windows file sharing mechanisms. FreeLocks suspends data processing, enabling the normal background processing of locks to occur, release locks on record pages, and make all data in your local Dynaset objects current.

  3. Increase the Space Allocation and Number of Locks allowed with the SHARE.EXE program. These settings default to 2048 bytes for Space Allocation, and 20 file Locks. This really is not much to work with - so if you are using Windows the settings need to be increased to 4096 (or higher), for Space Allocation, and 500 File Locks. To change these settings modify the line in your AUTOEXEC.BAT file so that it looks something like the below.
    "SHARE /F:4096 /L:500"



Written by: Rafael Merino
August '96

Image of Arrow linked to Previous Article Image of Arrow linked to Next Article
Image of Line Break
[HOME] [TABLE OF CONTENTS] [SEARCH]