Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Mar 1997 14:06:19 +0200 (EET)
From:      Narvi <narvi@haldjas.folklore.ee>
To:        hackers@freebsd.org
Subject:   realloc in 2.2
Message-ID:  <Pine.BSF.3.95.970307135956.1344A-100000@haldjas.folklore.ee>

next in thread | raw e-mail | index | archive | help

Well... I did a test on the memory use incurred by using realloc to grow a
memory area. The area seems to grow a bit too large - or am I
misinterpreting something? There is no /etc/malloc.conf and no malloc
options are set in the environment or otherwise.

The source of the quick hack is :

#include <stdlib.h>
#include <stdio.h>

main()
{
void *p;
unsigned i;
unsigned long j;
p=malloc(1024);

for (i=0; i<1024; ++i)
	{
	j=1024+(i+1)*1024;
	p=realloc(p, j);
	}
printf ("%u\n", j);
}

The result of /usr/bin/time -l is:


haldjas: {5} /usr/bin/time -l ./re
1049600
        6.11 real         4.51 user         1.52 sys
      2600  maximum resident set size
         3  average shared memory size
      1413  average unshared data size
       125  average unshared stack size
     16528  page reclaims
         0  page faults
         0  swaps
         0  block input operations
         0  block output operations
         3  messages sent
         3  messages received
         0  signals received
         3  voluntary context switches
        98  involuntary context switches

	Sander




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.970307135956.1344A-100000>