Freeing slice without knowing it’s size

This page summarizes the projects mentioned and recommended in the original post on /r/rust

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • pointer-utils

    A collection of small utilities for working with pointer types in Rust.

  • I think you can use slice-dst which embed the size of the array in the heap allocation and returns a thin pointer

  • generational-arena

    Discontinued A safe arena allocator that allows deletion without suffering from the ABA problem by using generational indices.

  • If you cannot inplace construct the slice-dst on heap and your slice is too large to be copied, then I think there are two solutions: - Using Box>, this adds another level of indirection but avoids the copying - Use an arena like slotmap, slab, generational_arena or concurrent_arena to store the Box<[u8]>. It still needs heap allocation, but it allocates in chunks, thus less fragmentation and performs better.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts