#singleton #memory #weak-references #leakdetection #referencecounting

aloe-memory

Aloe Memory provides advanced memory management functionalities, including reference counting, weak references, singleton patterns, and memory leak detection. This crate is a translation of the c++ juce module serving the same function.

2 releases

Uses new Rust 2024

new 0.1.1 Apr 2, 2025
0.1.0 Apr 2, 2025

#48 in #singleton

Download history 102/week @ 2025-03-28

102 downloads per month
Used in 195 crates (94 directly)

GPL-3.0 license

210KB
1.5K SLoC

Aloe Memory

aloe-memory is a Rust library offering advanced memory management utilities, including reference counting, weak references, and singleton patterns, specifically catered towards applications that require precise control over memory resources.

Features

  • Reference Counting: Easily add reference-counting capabilities to your objects, providing automatic memory management in multithreaded environments.
  • Weak References: Generate weak references that become null automatically when the referenced object is deleted.
  • Singletons: Utilize macros to implement singletons efficiently and safely, including multithreaded and single-threaded variants.
  • Heap Management: Manage dynamic memory allocations with classes like HeapBlock and MemoryBlock, providing array management and alignment functionalities.
  • Memory Leak Detection: Employ tools such as HeavyweightLeakedObjectDetector for robust memory leak detection and management.
  • Scoped Pointers: Implement OptionalScopedPointer to handle object lifetimes effectively, similar to C++'s RAII paradigm.

Usage

To use aloe-memory, include it in your Cargo.toml:

[dependencies]
aloe-memory = "0.1.0"

Example

Reference Counting Example:

use aloe_memory::{ReferenceCountedObject, ReferenceCountedObjectPtr};

struct MyObject {
    ref_counted_obj: ReferenceCountedObject,
}

impl ReferenceCountedObject for MyObject {
    // Implement necessary trait methods
}

let obj = ReferenceCountedObjectPtr::new(MyObject { ref_counted_obj: ReferenceCountedObject::default() });

Authors

This project is authored by Klebs (tpk3.mx@gmail.com).

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Disclaimer: This README.md file was generated by an AI model and may not be 100% accurate; however, it should be quite comprehensive.

This crate is a translation of the JUCE module.

JUCE is a c++ software framework for developing high performance audio applications.

Usage falls under the GPLv3 as well as the JUCE commercial license.

See github.com/juce-framework/JUCE and the JUCE license page for details.

This crate is in the process of being translated from c++ to rust. For progress updates, please see the workspacer rust project. designed specifically for rust projects.

Dependencies

~12–26MB
~358K SLoC