vmstat WARNS6 cleanup

Matthew Dillon dillon at apollo.backplane.com
Sat Jan 8 13:17:17 PST 2005


:On Sat, Jan 08, 2005 at 08:48:34PM +0100, Peter Schuller wrote:
:> Yes, I am aware of this. Hence any use of alloca is going to be an optimiation
:> only, conditional on the buffer size being below some small value -> malloc
:> would be required anyway so it doesn't solve the exit path issue.
:
:In almost all cases, malloc is better than alloca, if only to warrant some
:extra care to free the memory and therefore keep track of what you
:allocated. Yes, this is exactly the reverse of Garbage Collection, but
:GC is not always The Right Thing (TM).
:
:Therefore patches to change alloca uses correctly into malloc / free uses
:or other great stack allocations are certainly welcome. Keep in mind though,
:that we don't bother about one or two pages of stack in a leaf function,
:but anything above let's say 32 pages [add other arbitrary value here]
:should be really investigated.
:
:Joerg

    Yah, I agree.  I would go further to say that alloca should just
    be removed from the utility source entirely.    Performance is 
    almost never an issue in the places where alloca is used, and
    when performance is an issue (the one time out of a hundred where it
    is), one would just pre-allocate or pre-cache or cache/realloc the
    required memory buffer.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Submit mailing list