#utilities #memory #allocator #define #defined #sizeof #tetsy #tetcoin #global-allocator #compile-time-error

sys no-std tetsy-util-mem

Collection of tetsy memory related utilities

Show the crate…

8 releases (5 breaking)

0.9.1 Jun 8, 2021
0.9.0 Feb 18, 2021
0.8.0 Mar 10, 2021
0.5.2 Feb 25, 2021
0.2.0 Feb 20, 2021

#7 in #sizeof

Download history 508/week @ 2025-04-30 181/week @ 2025-05-07 107/week @ 2025-05-14 125/week @ 2025-05-21 39/week @ 2025-05-28 38/week @ 2025-06-04 80/week @ 2025-06-11 361/week @ 2025-06-18 387/week @ 2025-06-25 221/week @ 2025-07-02 437/week @ 2025-07-09 428/week @ 2025-07-16 368/week @ 2025-07-23 189/week @ 2025-07-30 235/week @ 2025-08-06 267/week @ 2025-08-13

1,121 downloads per month
Used in 217 crates (30 directly)

MIT/Apache

61KB
1K SLoC

tetsy-util-mem

Collection of memory related utilities.

WARNING

When tetsy-util-mem is used as a dependency with any of the global allocator features enabled, it must be the sole place where a global allocator is defined. The only exception to this rule is when used in a no_std context or when the estimate-heapsize feature is used.

Because of that, it must be present in the dependency tree with a single version. Starting from version 0.6.1, having duplicate versions of tetsy-util-mem will lead to a compile-time error. It still will be possible to have 0.5 and 0.6.1 versions in the same binary though.

Unless heeded you risk UB; see discussion in issue 364.

Features

  • estimate-heapsize : Do not use allocator, but size_of or size_of_val.

Others features define global allocator, see src/alloc.rs.

Dependency

This crate groups common dependency, a patched copy of unpublished malloc_size_of from servo project is copied and partially reexported.

Malloc_size_of code is used internally as a module with a few modification to be able to implement type locally.

For existing code using deprecated HeapsizeOf crate, calls to heapsize_of_children should be replace by calls to size_of.

Dependencies

~2–13MB
~98K SLoC