Win16 Memory Management
2 days ago
- #NE Format
- #Memory Management
- #16-bit Windows
- Windows 16-bit memory management was complex due to 8086 real mode limitations and was not well documented for application developers.
- Windows acted as an overlay manager, using movable and discardable segments to manage limited RAM, requiring careful handling by programmers.
- The New Executable (NE) format enabled segment-based loading, moving, and reloading, with imports/exports for external calls like window procedures.
- Memory segments were identified by handles, not addresses, requiring locking/unlocking via GlobalLock and GlobalUnlock to access them safely.
- Segments had attributes: fixed/movable and discardable/nondiscardable, with code typically discardable and data nondiscardable.
- DLLs in Windows used the NE format, had no own stack, and required special compiler switches (/Aw, /Gw) for proper prolog/epilog generation.
- Function prologs and epilogs were patched by Windows to manage data segment addresses and stack walking for memory movement.
- OS/2 in protected mode simplified memory management by using hardware support, eliminating need for GlobalLock/Unlock and special prologs.
- Tools like SHAKER and HEAPWALK in SDKs helped test memory management under stress, revealing bugs in segment handling.
- Memory management required strict discipline; incorrect compiler switches, exports, or locking could cause failures.