summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.3
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-10-08 18:44:20 +0000
committerphk <phk@FreeBSD.org>1995-10-08 18:44:20 +0000
commitb965b1036f34a44927d0103fb1d6c68e5e558787 (patch)
treed4fc48ffedc32f33454219ed82939e547105483b /lib/libc/stdlib/malloc.3
parent0f62a1bc9292605b0b5581acdc61ced2ebbd8712 (diff)
downloadFreeBSD-src-b965b1036f34a44927d0103fb1d6c68e5e558787.zip
FreeBSD-src-b965b1036f34a44927d0103fb1d6c68e5e558787.tar.gz
phkmalloc/2
"zero' and 'junk' options to help find and diagnose malloc abuse. EXTRA_SANITY defaults "junk" to on. Don't dump the internal state, unless EXTRA_SANITY. General code cleanup. Error messages cleaned up a bit, more checking earlier. EXTRA_SANITY is default at this time (just in case). Performance (without EXTRA_SANITY) is better, beats gnumalloc in both time & space most of the time: # In-memory test. ./malloc 50000000 2000 8192 159.2u 1.5s 2:41.85 99.3% 5+7742k 0+0io 0pf+0w ./gnumalloc 50000000 2000 8192 272.6u 0.4s 4:35.01 99.3% 5+8533k 0+0io 0pf+0w # Swap-space test. ./malloc 500000 14000 8192 6.5u 4.1s 4:08.87 4.3% 5+49209k 0+0io 9772pf+0w ./gnumalloc 500000 14000 8192 16.2u 14.5s 15:36.14 3.2% 5+54100k 0+0io 47651pf+0w # Small items test. ./malloc 20000000 20000 2048 67.0u 0.3s 1:07.83 99.2% 5+18199k 0+0io 4pf+0w ./gnumalloc 20000000 20000 2048 66.2u 0.3s 1:07.03 99.3% 5+18107k 0+0io 0pf+0w SANITY is not an option anymore. (!!)
Diffstat (limited to 'lib/libc/stdlib/malloc.3')
-rw-r--r--lib/libc/stdlib/malloc.337
1 files changed, 17 insertions, 20 deletions
diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3
index b191415..94a3fd6 100644
--- a/lib/libc/stdlib/malloc.3
+++ b/lib/libc/stdlib/malloc.3
@@ -111,25 +111,6 @@ is zero and
is not a null pointer, the object it points to is freed.
.Pp
-.Pp
-The default is to compile with the ``SANITY'' option,
-which trades a couple of percent of performance for rather rigorous
-sanity checking of the arguments passed to
-.Xr free
-and
-.Xr realloc .
-.Pp
-If compiled without the ``SANITY'' option and the argument does not
-match a pointer earlier returned by the
-.Xr calloc ,
-.Xr malloc ,
-or
-.Xr realloc
-function, or if the space has been deallocated by a call to
-.Fn free
-or
-.Xr realloc ,
-general havoc will be imminent.
.Sh ENVIRONMENT
This malloc will check the environment for a variable called
.Em MALLOC_OPTIONS
@@ -139,15 +120,31 @@ Flags are single letters, uppercase means on, lowercase means off.
.It A
``abort'' malloc will coredump the process, rather that tollerate failure.
This is a very handy debugging aid, since the core file will represent the
-time of failure, rather than when the NULL pointer was accessed.
+time of failure,
+rather than when the NULL pointer was accessed.
+
.It D
``dump'' malloc will dump statistics in a file called ``malloc.out'' at exit.
+
+.It J
+``junk'' fill some junk into the area allocated.
+Currently junk is bytes of 0xd0, this is pronounced ``Duh'' :-)
+
.It R
``realloc'' always reallocate when
.Fn realloc
is called, even if the initial allocation was big enough.
This can substantially aid in compacting memory.
+
+.It Z
+``zero'' fill some junk into the area allocated (see ``J''),
+except for the exact length the user asked for, which is zerod.
+
.El
+.Pp
+The ``J'' and ``Z'' is mostly for testing and debugging,
+if a program changes behaviour if either of these options are used,
+it is buggy.
.Sh RETURN VALUES
The
.Fn malloc
OpenPOWER on IntegriCloud