Memory Models

John Cowan cowan at marob.masa.com
Tue Aug 15 03:36:31 AEST 1989


In article <10703 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <562 at dcscg1.UUCP> drezac at dcscg1.UUCP (Duane L. Rezac) writes:
>>I am just getting into C and have a question on Memory Models.
>
>That is not a C language issue.  It's kludgery introduced specifically
>in the IBM PC environment.  Unless you have a strong reason not to,
>just always use the large memory model.  (A strong reason would be
>compatibility with an existing object library, for example.)


I have to disagree here.  "Always use the large memory model" is a
prescription for disaster under MS-DOS, due to the use of real mode.
Large model programs use pointers that, if damaged by bugs, can access
every part of memory, including the operating system.  Using small model
whenever possible gives a modicum of protection: at most, runaway pointers
can access up to 64K, most of which is probably above the current program
and not in use by anybody.  This makes operating system crashes far less
likely: at most, the program goes down without taking DOS with it.

I use the small model exclusively when writing programs small enough to fit
into it.  Only if needed do I fire up the large model.  I agree that, modulo
the question of compatibility with existing libraries, the other models are
not very useful.
-- 
Internet/Smail: cowan at marob.masa.com	Dumb: uunet!hombre!marob!cowan
Fidonet:  JOHN COWAN of 1:107/711	Magpie: JOHN COWAN, (212) 420-0527
		Charles li reis, nostre emperesdre magnes
		Set anz toz pleins at estet in Espagne.



More information about the Comp.lang.c mailing list