System V.2 and growing processes

Christoph Kuenkel ckl at uwbln.UUCP
Tue Jan 10 00:44:01 AEST 1989


In article <10746 at rpp386.Dallas.TX.US>, jfh at rpp386.Dallas.TX.US (John F. Haugh II) writes:
> Well, now you know ;-)  Had a realloc been added these problems wouldn't
> exist.  I had added a realloc() which tested for adjacency and it resolved
> this problem partially.  The conclusion I reached was that processes
> should allocate physical memory in large chunks and then manage the
> unused space, rather than growing one click at a time.
> 
My solution is to estimate the maximum size of dynamic memory a process will
need and code something like:

    ...
    register char *p;

    p = malloc(ESTIMATED_SIZE);			/* 1. */
    (void) malloc(1);				/* 2. */
    free(p);

Step 1 is to grow the process with a single swap out/swap in, step 2 is
to avoid shrinking of the process's break value.

Seems to work quite fine.  Is it much more stupid than I realize?
(Yes, I dont use the maximum size for long-running programs with extensively
varying memory usage)

christoph
-- 
# include <std/disclaimer.h>
Christoph Kuenkel/UniWare GmbH       Kantstr. 152, 1000 Berlin 12, West Germany
ck at tub.BITNET                ckl at uwbln             {unido,tmpmbx,tub}!uwbln!ckl



More information about the Comp.unix.wizards mailing list