Win16 Memory Management

TL;DR

This article explains how Win16’s memory management works, focusing on segments, handles, and the mechanisms that allowed Windows to efficiently manage limited memory. It highlights confirmed technical details and ongoing uncertainties about the system’s full implementation.

Recent technical analysis has clarified how 16-bit Windows managed memory through segments and handles, revealing the underlying mechanisms that allowed Windows to operate efficiently within limited hardware constraints. This understanding matters because it sheds light on the foundational architecture of early Windows systems, which influenced later memory management models.

The core of Windows 16-bit memory management revolved around segments, which are contiguous blocks of memory up to 64KB in size. Unlike direct segment addresses used in pure 8086 programming, Windows identified segments via opaque handles—16-bit values that serve as references rather than direct addresses. These handles are akin to protected mode selectors but are used in real mode environments to enable Windows to move and discard segments without losing track of them.

Windows adopted and extended the ‘New Executable’ (NE) format, which stored segments separately on disk, allowing for individual loading, unloading, and relocation in memory. When a program needs to access a segment, it calls APIs like GlobalAlloc, which returns a handle, and GlobalLock, which provides a segment address and locks the segment in place. Unlocking with GlobalUnlock allows the segment to be moved again, with the handle remaining valid as a reference.

This handle-based system enabled Windows to implement a form of memory management that was flexible yet constrained by the hardware of the era. The design was inspired by Intel 286 protected mode, though Windows itself operated primarily in real mode, requiring additional discipline and API support to emulate protected mode features.

Why It Matters

This memory management approach was critical for Windows’ ability to run multiple applications simultaneously on limited hardware, effectively acting as an overlay manager. Understanding this system clarifies how early Windows overcame hardware limitations and laid the groundwork for modern memory management concepts. It also provides context for developers working with legacy systems or emulators.

Amazon

16-bit Windows memory management book

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Windows 1.x and 2.x operated in a constrained environment where paging was unavailable, and memory was scarce. The adoption of the NE format and segment handles was a response to these limitations, enabling Windows to load, move, and unload application code dynamically. This architecture persisted through Windows 3.x, influencing later Windows versions, though the system evolved significantly with the advent of protected mode and 32-bit architectures.

“Handles serve as a level of indirection, allowing Windows to move segments around without breaking references.”

— Steve Wood, Windows 1.0 memory designer

Amazon

legacy DOS memory management tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

While the general principles of handle and segment management are understood, the detailed implementation, particularly how Windows optimized segment relocation and handle management in practice, remains partially undocumented. It is also unclear how these mechanisms evolved in later Windows versions beyond Windows 3.x.

Retro-Bit Sega Genesis 2.4 GHz Wireless Controller 8-Button Arcade Pad for Sega Genesis Original/Mini, Nintendo Switch, PC, Mac – Includes 2 Receivers & Storage Case - Black

Retro-Bit Sega Genesis 2.4 GHz Wireless Controller 8-Button Arcade Pad for Sega Genesis Original/Mini, Nintendo Switch, PC, Mac – Includes 2 Receivers & Storage Case – Black

2.4GHz Officially-licensed Wireless Controller

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Further research aims to uncover detailed source code or detailed documentation that clarifies the internal algorithms Windows used for segment relocation and handle management. Additionally, exploring how these legacy systems influenced modern memory management could provide valuable insights.

Attoe Wireless Gaming Mouse, Tri-Mode 2.4G/Bluetooth/USB-C, 24000 DPI, 12 Programmable Buttons, 500mAh Rechargeable Battery, 7 RGB Lighting Modes, On-Board Memory for Laptop/PC/Mac (Black)

Attoe Wireless Gaming Mouse, Tri-Mode 2.4G/Bluetooth/USB-C, 24000 DPI, 12 Programmable Buttons, 500mAh Rechargeable Battery, 7 RGB Lighting Modes, On-Board Memory for Laptop/PC/Mac (Black)

【Tri-Mode Connectivity for Total Freedom】: Break free from cable clutter and experience versatile connectivity. Seamlessly switch between ultra-fast…

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

How did Windows manage to run multiple applications with limited memory?

Windows used segments and handles to load, move, and unload parts of applications dynamically, acting as an overlay manager that kept only active segments in physical memory.

What is the significance of the NE format in Windows memory management?

The NE format stored segments separately on disk, enabling Windows to load and unload segments individually, which was crucial for managing limited memory resources.

Are these memory management techniques still relevant today?

While modern systems use paging and virtual memory, the handle-based approach influenced later memory management models and remains a foundational concept in understanding legacy Windows systems.

What remains unknown about Windows 16-bit memory management?

Exact internal algorithms for segment relocation, handle management optimizations, and how these evolved in later Windows versions are still not fully documented or understood.

Source: Hacker News

You May Also Like

Charm Your Home With Energy-Saving Heat Pumps

Are you fed up with exorbitant energy bills and ineffective heating systems?…

Three Key Insights: Heat Pump Efficiency in Renewables

We have the inside information on three important factors affecting the efficiency…

Beginner’s Guide to Heat Pump Energy Efficiency Ratings

Welcome to our beginner’s guide on heat pump energy efficiency ratings. Understanding…

Revamping Heat Pump Efficiency With Renewable Energy: Key Tips

Are you looking to boost your heat pump efficiency with renewable energy?…