Microsoft KB Archive/59121

= How to Change the Way MS-DOS Allocates Memory =

Article ID: 59121

Article Last Modified on 11/16/2006

-

APPLIES TO


 * Microsoft MS-DOS 3.1
 * Microsoft MS-DOS 3.2 Standard Edition
 * Microsoft MS-DOS 3.21 Standard Edition
 * Microsoft MS-DOS 3.3 Standard Edition
 * Microsoft MS-DOS 3.3a
 * Microsoft MS-DOS 4.0 Standard Edition
 * Microsoft MS-DOS 4.01 Standard Edition
 * Microsoft MS-DOS 5.0 Standard Edition

-



This article was previously published under Q59121



SUMMARY
When MS-DOS allocates memory for your program, it uses a first-fit allocation strategy by default. You can change MS-DOS's default strategy to a best fit, last fit, or back to first fit with a call to INT 21h Function 58h.



MORE INFORMATION
A first-fit strategy forces MS-DOS to search from low addresses in memory to high addresses, and allocate the first available block of memory large enough for the requested allocation.

A best-fit strategy forces MS-DOS to search all addresses in memory and allocate the smallest block still large enough to fill the requested allocation.

A last-fit strategy forces MS-DOS to search from high addresses in memory to low addresses, and allocate the first available block of memory large enough for the requested allocation.

The best-fit algorithm is the slowest to execute since all free memory is searched, but results in the least memory fragmentation during multiple allocations and frees. Conversely, the first-fit and last-fit strategies are fastest to execute but result in a higher degree of memory fragmentation.

Additional query words: 3.00 3.10 3.20 3.21 3.22 3.30 3.30a 4.00 4.00a 4.01 5.00 noupd

Keywords: KB59121

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.