The huge memory model is nearly identical to the large model. The only difference is that the huge model permits individual arrays to exceed 64K in size. For example, an int uses two bytes, so an array of 40,000 integers, occupying 80,000 bytes of memory, would be permitted in the huge model. All other models limit each array, structure, or other data object to no more than 64K.
Note:
Automatic arrays cannot be declared huge. Only static arrays and arrays occupying memory allocated by the _halloc function can be huge.
Summary: The huge model lifts the limits on arrays.
Although the huge model lifts the limits on arrays, some size restrictions do apply. To maintain efficient addressing, no individual array element is allowed to cross a segment boundary. This has the following implications:
No single element of an array can be larger than 64K. An array can be larger than 64K, but its individual elements cannot.
For any array larger than 128K, all elements must have a size in bytes equal to a power of 2: 2 bytes, 4 bytes, 8 bytes, 16 bytes, and so on. If the array is 128K or smaller, its elements can be any size, up to and including 64K.
Pointer arithmetic changes within the huge model, as well. In particular, the sizeof operator may return an incorrect value for huge arrays. The ANSI draft standard for C defines the value returned by sizeof to be of type size_t (which, in Microsoft C, is an unsigned int). The size in bytes of a huge array is an unsigned long value, however. To find the correct value, you must use a type cast:
(unsigned long)sizeof( monster_array )
Similarly, the C language defines the result of subtracting two pointers as ptrdiff_t (a signed int in Microsoft C). Subtracting two huge pointers will yield a long value. Microsoft C gives the correct result with the following type cast:
(long)(ptr1__huge - ptr2_huge)
When you select huge model, all extern and uninitialized arrays are treated as __huge. Operations on data declared as _huge can be less efficient than the same operations on data declared as __far.