Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!decvax!genrad!panda!talcott!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: malloc(), virtual memory Message-ID: <1506@umcp-cs.UUCP> Date: Fri, 6-Sep-85 13:42:12 EDT Article-I.D.: umcp-cs.1506 Posted: Fri Sep 6 13:42:12 1985 Date-Received: Tue, 10-Sep-85 20:28:33 EDT References: <1285@brl-tgr.ARPA> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 23 > From: jon@cit-vax (Jonathan P. Leech) >> From: Chris Torek >> ... Since as distributed 4.2 has a per-process VM limit of 6M, you >> cannot allocate more than 4M with malloc. > I don't understand how this works. Suppose I allocate two blocks, > one 4M (2^22 bytes) and one 2M (2^21). These are both powers of > two, and I get 6M total. Or does malloc round it up by a factor > of two if you are unlucky enough to request a power of two . . . . Sorry, I was not specific enough. You can allocate one 4M chunk and one 2M chunk; you cannot allocate one 6M chunk. The size you hand to malloc has (in our C library at any rate) 4 added to it, then the result is brought up to the nearest power of two. So if you give it ((1 << 22) - 4) you will get a 4M chunk; one more byte and malloc will require an 8M chunk. (If you compile malloc with range checking the overhead grows to 12 bytes.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland