Windows 3.11 Memory Allocation System Library

In Microsoft Windows 3.11, core operating system services such as task scheduling and memory management were governed by the Windows Kernel module. This article details the specific system library responsible for exposing memory allocation routines to applications running on Windows 3.11, how it was structured internally, and the primary application programming interfaces (APIs) it provided.

The Kernel Library (KRNL386.EXE)

In Windows 3.11 (specifically Windows for Workgroups 3.11, which ran exclusively in 386 Enhanced Mode), the system library that provided memory allocation functions to programs was the Windows Kernel, implemented by the executable dynamic-link library file KRNL386.EXE (referenced logically by applications simply as KERNEL).

Earlier versions of 16-bit Windows also included KERNEL.EXE (for Real Mode) and KRNL286.EXE (for Standard Mode on 80286 processors). Because Windows 3.11 removed support for Real and Standard modes, KRNL386.EXE served as the sole implementation of the KERNEL module.

Memory Allocation Functions Provided

Applications interacting with the Windows 3.11 API invoked memory management functions exported by KERNEL. Memory in 16-bit Windows was bifurcated into the Global Heap and Local Heaps:

  • Global Heap Functions: Provided system-wide memory segments to applications. Key functions included:

    • GlobalAlloc: Allocated a specified number of bytes from the global heap and returned a memory handle (HGLOBAL).
    • GlobalReAlloc: Resized an existing global memory block.
    • GlobalFree: Released an allocated block back to the system.
    • GlobalLock and GlobalUnlock: Converted a movable memory handle into a 16:16 far pointer for direct access and unlocked it when finished.
  • Local Heap Functions: Allowed a program to allocate dynamic memory out of its own dedicated 64 KB local data segment (DS). Key functions included:

    • LocalAlloc: Allocated memory within the calling application's local heap.
    • LocalReAlloc: Resized a local memory allocation.
    • LocalFree: Released a local memory block.
    • LocalLock and LocalUnlock: Provided near pointers to movable local heap memory blocks.

Underlying Virtual Memory Management

While KRNL386.EXE provided the user- and application-facing memory allocation APIs, it relied on WIN386.EXE at the lowest level. In 386 Enhanced Mode, WIN386.EXE served as the Virtual Machine Manager (VMM) and DOS Protected Mode Interface (DPMI) host. The VMM handled paging, linear-to-physical address translation, and swap file management (virtual memory) on the 80386 or compatible processor, while KRNL386.EXE translated these low-level services into the standard 16-bit segment-based memory API consumed by Windows software.