Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > muc.lists.netbsd.tech.userlevel > #11761

Re: Where's 9.1's malloc?

From Martin Husemann <martin@duskware.de>
Newsgroups muc.lists.netbsd.tech.userlevel
Subject Re: Where's 9.1's malloc?
Date 2026-05-15 15:45 +0200
Organization Newsgate at muc.de e.V.
Message-ID <agcjkMtErQu_ri8B@big-apple.aprisoft.de> (permalink)
References <202605151311.JAA02398@Stone.Rodents-Montreal.ORG>

Show all headers | View raw


On Fri, May 15, 2026 at 09:11:35AM -0400, Mouse wrote:
> Where is the source for 9.1's malloc implementation?

See lib/libc/README:

   In the implementation of libc, malloc and free are defined normally
   in src/lib/libc/stdlib/jemalloc.c:

and:

lib/libc/stdlib/Makefile.inc:

.if ${RUMPRUN} != "yes"
.   if (${USE_JEMALLOC} != "no")
.      if ${HAVE_JEMALLOC} > 100
.         include "${NETBSDSRCDIR}/external/bsd/jemalloc/lib/Makefile.inc"
.      else
SRCS+=  jemalloc.c aligned_alloc.c
.      endif
.   else
SRCS+=  malloc.c
.   endif
.endif

Then look at share/mk/bsd.own.mk for the default of HAVE_JEMALLOC:

#
# What version of jemalloc we use (100 is the one
# built-in to libc from 2005 (pre version 3).
#
HAVE_JEMALLOC?=         510

and the final piece is pretty much hidden in distrib/utils/libhack/Makefile.inc
where the smaller (ancient) version from lib/libc/stdlib/jemalloc.c
gets used for environments where binary size needs to be absolutely minimal.

So much for netbsd-9.

We do use the old (small) version on some architectures in newer branches,
e.g. the bsd.own.mk from netbsd-10 and netbsd-11 both have:

#
# What version of jemalloc we use (100 is the one
# built-in to libc from 2005 (pre version 3).
#
.if ${MACHINE_ARCH} == "vax" || ${MACHINE} == "sun2"
HAVE_JEMALLOC?=         100
.else
HAVE_JEMALLOC?=         510
.endif



Martin

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de

Back to muc.lists.netbsd.tech.userlevel | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Where's 9.1's malloc? Mouse <mouse@Rodents-Montreal.ORG> - 2026-05-15 09:11 -0400
  Re: Where's 9.1's malloc? Martin Husemann <martin@duskware.de> - 2026-05-15 15:45 +0200
    Re: Where's 9.1's malloc? Mouse <mouse@Rodents-Montreal.ORG> - 2026-05-15 10:24 -0400

csiph-web