Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!yetti!geac!daveb From: daveb@geac.UUCP Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Optimizing use of malloc Message-ID: <1665@geac.UUCP> Date: Thu, 22-Oct-87 15:02:15 EDT Article-I.D.: geac.1665 Posted: Thu Oct 22 15:02:15 1987 Date-Received: Sat, 24-Oct-87 12:00:50 EDT References: <7264@brl-adm.ARPA> <1015@cup.portal.com> <126@fxgrp.UUCP> Reply-To: daveb@geac.UUCP (Dave Collier-Brown) Organization: The little blue rock next to that twinkly star. Lines: 37 Keywords: malloc Xref: yetti comp.lang.c:4772 comp.unix.questions:4096 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: bsd 4.2, bsd4.3, -- long sun 3.*, -- not known, probably int (its a 68k) ultrix 32, -- long sys v (various releases & systems) -- varies with machine 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. You may find that the cost of the malloc header dominates the cost of alignment: I wrote a paranoid/debugging allocator for GCOS 8 and discovered header-size to be significant on that machine (which needed long alignment). --dave (I couldn't get through to you by mail) c-b -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months. -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.