Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!chris%umcp-cs.uucp@BRL.ARPA From: chris%umcp-cs.uucp@BRL.ARPA (Chris Torek) Newsgroups: net.lang.c Subject: Re: malloc(), virtual memory Message-ID: <1371@brl-tgr.ARPA> Date: Sun, 8-Sep-85 16:55:26 EDT Article-I.D.: brl-tgr.1371 Posted: Sun Sep 8 16:55:26 1985 Date-Received: Tue, 10-Sep-85 04:01:52 EDT Sender: news@brl-tgr.ARPA 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