Chris Kennelly CA 26e4a562cf Reset GuardedPageAllocator slot deallocation state on reservation.
GuardedPageAllocator::Allocate previously cleared deallocation state only after unprotecting the page, leaving a window after ReserveFreeSlot where concurrent error classification saw a stale kUseAfterFree and a racing double-free could unprotect or free a reallocated slot. Reset deallocation state under guarded_page_lock_ in ReserveFreeSlot, re-protect before ForceTouchPage and gate FreeSlot on dealloc_count == 1 in Deallocate, and access concurrent SlotMetadata error-reporting fields atomically.
PiperOrigin-RevId: 1006355971
2026-10-24 10:58:21 -07:00
2026-10-20 09:57:20 -07:00
2026-10-20 09:57:20 -07:00
2024-06-10 09:16:07 -07:00
2024-06-10 09:16:07 -07:00
2020-02-07 17:55:59 -05:00
2020-02-07 17:55:59 -05:00

TCMalloc

This repository contains the TCMalloc C++ code.

TCMalloc is Google's customized implementation of C's malloc() and C++'s operator new used for memory allocation within our C and C++ code. TCMalloc is a fast, multi-threaded malloc implementation.

Building TCMalloc

Bazel is the official build system for TCMalloc. Experimental support for CMake is available as well.

The TCMalloc Platforms Guide contains information on platform support for TCMalloc.

Documentation

All users of TCMalloc should consult the following documentation resources:

  • The TCMalloc Quickstart covers downloading, installing, building, and testing TCMalloc, including incorporating within your codebase.
  • The TCMalloc Overview covers the basic architecture of TCMalloc, and how that may affect configuration choices.
  • The TCMalloc Reference covers the C and C++ TCMalloc API endpoints.

More advanced usages of TCMalloc may find the following documentation useful:

  • The TCMalloc Tuning Guide covers the configuration choices in more depth, and also illustrates other ways to customize TCMalloc. This also covers important operating system-level properties for improving TCMalloc performance.
  • The TCMalloc Design Doc covers how TCMalloc works underneath the hood, and why certain design choices were made. Most developers will not need this level of implementation detail.
  • The TCMalloc Compatibility Guide which documents our expectations for how our APIs are used.

License

The TCMalloc library is licensed under the terms of the Apache license. See LICENSE for more information.

Disclaimer: This is not an officially supported Google product.

Languages
C++ 92.8%
Starlark 3.6%
CMake 2.8%
Assembly 0.6%
C 0.2%