3

What libc implementation is used in Android platform? What malloc implementation is used (ptmalloc or tcmalloc or anything other)?

osgx
  • 90,338
  • 53
  • 357
  • 513

1 Answers1

7

libc is Bionic and malloc is Doug Lea version named dlmalloc (with USE_LOCKS enabled for thread-safety).

Update: dlmalloc was removed in january 2016: https://github.com/android/platform_bionic/commit/c650447239352d43acc2fd99a8579a85ae0469ab https://sourceforge.net/p/android-x86/bionic/ci/0ac0cee0d1ab60a92103a5021e76ec31da2e3234/ "Merge "Remove dlmalloc.""

+libc_malloc_src := bionic/jemalloc_wrapper.cpp
+libc_common_c_includes += external/jemalloc/include

So, Android 7 uses external malloc implementation jemalloc (from FreeBSD/Facebook) - http://jemalloc.net/ and https://github.com/jemalloc/jemalloc; android variant of code is there: https://android.googlesource.com/platform/external/jemalloc/

osgx
  • 90,338
  • 53
  • 357
  • 513
  • 1
    For reference, here's the source code for the dlmalloc used by Android (git master): https://android.googlesource.com/platform/bionic.git/+/master/libc/upstream-dlmalloc/ – Ilya Oct 16 '12 at 03:14
  • Other link for source code: http://code.metager.de/source/xref/android/4.4/bionic/libc/upstream-dlmalloc/ (5 This code is imported from: ftp://g.oswego.edu/pub/misc/ 6 It is currently version 2.8.6.). Still here at android 6: https://android.googlesource.com/platform/bionic/+/android-6.0.1_r55/libc/upstream-dlmalloc/ but not in android 7: https://android.googlesource.com/platform/bionic/+/android-7.0.0_r27/libc/ – osgx Feb 16 '17 at 13:21