Thanks to visit codestin.com
Credit goes to lib.rs

#memory-allocator #tc-malloc #performance #api-bindings

no-std tcmalloc-better

A Rust wrapper over Google's TCMalloc memory allocator

20 releases

Uses new Rust 2024

0.1.19 Jun 16, 2025
0.1.18 Jun 16, 2025
0.1.13 May 30, 2025

#276 in Memory management

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

6,548 downloads per month
Used in malloc-best-effort

MIT license

2.5MB
53K SLoC

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

TCMalloc better

A Rust wrapper over Google's TCMalloc memory allocator

Latest Version Documentation

A drop-in global allocator wrapper around the TCMalloc allocator. TCMalloc is a general-purpose, performance-oriented allocator built by Google.

Comparison with other tcmalloc wrappers

Current TCMalloc wrappers rely on gperftools, which has been in a detached state from the main development branch for over 10 years and lacks modern features such as per-CPU caching.

  • tcmalloc - Cons:
    • Outdated wrapper, which does not updates for years
    • Depends on gperftools-2.7
  • tcmalloc2 - Cons:
    • Wrapper which can not build in offline mode
    • Depends on gperftools-2.16

Caveats

This library is intended for use on Linux (x86_64, aarch64). For applications requiring support on a broader range of platforms, consider using malloc-best-effort, which automatically selects the best allocator based on the target platform.

Usage

use tcmalloc_better::TCMalloc;

#[global_allocator]
static GLOBAL: TCMalloc = TCMalloc;

fn main() {
    TCMalloc::process_background_actions_thread();

    // Rest of main
}

Requirements

A C++ compiler is required for building TCMalloc with cargo.

See also

  • malloc-best-effort - library, which automatically selects the best suited allocator based on the target platform

Dependencies