PreviousProgrammer's Guide (v9 SP2 (9.5) revision 1) Next

Reducing Wasted Space in Files

Chapter contents

The MicroKernel allocates disk space as needed. If there is not enough room in the file when your application inserts new records, the MicroKernel dynamically allocates additional data and index pages to the file. The size of each allocated page is the same as the page size with which the file was created. The MicroKernel also updates directory structures to reflect the new file size.

Once the MicroKernel allocates space to a file, that space remains allocated as long as the file exists.

To reduce the space required for a file from which numerous records have been deleted, you can use the Maintenance utility as follows:

  1. Create a new file with the same characteristics as the original file.
  2. In the interactive Maintenance utility, the commands are Open and Create As from the File menu. In the command-line based Maintenance utility, the command is CLONE.

  3. Insert records into the new file using one of the following methods:
    • Write a small application that reads the records from the original file and inserts them into the new file.
    • In the command-line Maintenance utility, use the SAVE command and then the LOAD command. Alternatively, you can use the COPY command.
    • In the interactive Maintenance utility, use the Save command and then the Load command from the Data menu. Alternatively, you can use the Copy command from the Data menu.
  4. Rename the new file and then delete the original file from the disk.

Chapter contents
Book contents

Prev topic: Engine Shutdowns and Connection Resets
Next topic: Btrieve API Programming