Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!mordor!lll-tis!ames!hc!beta!unm-la!unmvax!mike From: mike@unmvax.UUCP Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Optimizing use of malloc Message-ID: <695@unmvax.unm.edu> Date: Mon, 2-Nov-87 01:34:50 EST Article-I.D.: unmvax.695 Posted: Mon Nov 2 01:34:50 1987 Date-Received: Wed, 4-Nov-87 06:07:22 EST References: <7264@brl-adm.ARPA> <1015@cup.portal.com> <126@fxgrp.UUCP> <1665@geac.UUCP> Sender: news@unmvax.unm.edu Reply-To: mike@turing.unm.edu (Michael I. Bushnell) Followup-To: comp.lang.c Organization: University of New Mexico, Albuquerque Lines: 36 Xref: utgpu comp.lang.c:4984 comp.unix.questions:4238 In-reply-to: daveb@geac.UUCP In article <1665@geac.UUCP>, daveb@geac writes: ~In article <4753@oberon.USC.EDU> you write: ~>Most versions of malloc will round the amount of memory you request to ~>some number convienient for it. Since the pointer returned must be ~>maximally alligned, this is normally a multiple of the size of the ~>largest type. What I need to know what sizes of memory requests to ~>malloc will reduce wasted space for a variety of systems: ~ The basic rule is laid down by the hardware designers: if a machine ~will fetch longwords from a byte address, its a don't-care. If it ~requires an even address, use int alignment. Otherwise use long. ~IBM /376's can require double! (/370's require long). ~ The information should vary mostly with cpu-chip, and can be ~obtained from CPU manuals. This is not the whole story. On BSD, malloc uses a binary buddy system. So, if you request 33 longs of data, you are liable to get more like 60. (Not 64, because there is some header information kept for free().) -- Michael I. Bushnell a/k/a Bach II mike@turing.unm.edu {ucbvax,gatech}!unmvax!turing!mike --- Those aren't WINOS--that's my JUGGLER, my AERIALIST, my SWORD SWALLOWER, and my LATEX NOVELTY SUPPLIER!! -- Zippy the Pinhead Michael I. Bushnell a/k/a Bach II mike@turing.unm.edu {ucbvax,gatech}!unmvax!turing!mike --- Those aren't WINOS--that's my JUGGLER, my AERIALIST, my SWORD SWALLOWER, and my LATEX NOVELTY SUPPLIER!! -- Zippy the Pinhead