Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ukma!rutgers!cmcl2!phri!marob!cowan From: cowan@marob.masa.com (John Cowan) Newsgroups: comp.lang.c Subject: Re: Memory Models Keywords: Memory models,C Message-ID: <24E70322.5CA8@marob.masa.com> Date: 14 Aug 89 17:36:31 GMT References: <562@dcscg1.UUCP> <10703@smoke.BRL.MIL> Reply-To: cowan@marob.masa.com (John Cowan) Organization: ESCC, New York City Lines: 28 In article <10703@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <562@dcscg1.UUCP> drezac@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@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.