Chapter 4 Managing Memory in C

When you develop advanced 16-bit applications with Microsoft C/C++, you must pay attention to memory management—that is, how data and code are stored and accessed in memory. A well-thought-out memory strategy will make your 16-bit programs run faster and occupy less memory.

You can follow one or more of these memory management strategies:

Choose a standard memory model.

Create a mixed-model program with the __near, __far, __huge, and __based keywords.

Create your own customized memory model.

Allocate memory as you need it with the malloc family of functions.

Use virtual memory with the _vmalloc family of functions.

This chapter explains pointers, memory models (including tiny model), variations such as custom memory models and mixed models, based pointers, and virtual memory.

Most of the material covered in this chapter is relevant only to 16-bit programs. The only topics described in this chapter that apply to 32-bit programs are pointers based on a pointer.