我只是在看glibc中malloc.c文件顶部的注释,它说:
You may already by default be using a C library containing a malloc
that is based on some version of this malloc (for example in
linux). You might still want to use the one in this file in order to
customize settings or to avoid overheads associated with library
versions.
我不明白为什么glibc代码会说Linux版本可能使用与glibc malloc.c中的代码不同的东西?有人可以帮忙重新写一下意思吗?我以为glibc malloc()是每个Linux用于内存管理的东西?
解决方法:
之所以这样说,是因为glibc中的malloc实现基于ptmalloc,该实现又基于Doug Lea malloc实现,这些注释都来自该实现.该malloc实现已导入,并在glibc 2.3版中设置为默认设置.
由于ptmalloc / Doug Lea的malloc实现是一个单独的库,您可以用来替换系统上的标准malloc(),这些注释都适用.但是在将该库引入glibc时保留了注释.
标签:malloc,c-3,memory-management,linux
来源: https://codeday.me/bug/20191030/1964721.html