Skip to content

feat: Add RAII-mode macro for memory management (minimal changes) #8

@scc-tw

Description

@scc-tw

Background

This project currently uses reference counting for memory management, primarily for CPython compatibility. To enable more aggressive memory compaction, we want to introduce a new macro to switch to RAII-mode memory management when desired.

Requirements

  • RAII Mode Activation:
    • Only enabled when -DRAII_MODE=ON is set via CMake option.
  • Macro Implementation:
    • Add a new macro to enable RAII-based memory management.
    • Use macro guards, but minimize their usage scope to only where necessary.
  • Code Quality:
    • Write clean, expert-level C++ code.
    • Minimal code changes: Only modify/refactor code directly impacted by the new macro.
  • Documentation Review:
    • Read all documentation in the docs/ folder to fully understand existing design and constraints before implementation. See the references below for a complete list of documents.
  • Compatibility:
    • When RAII is not enabled, retain the current reference counting approach for CPython compatibility.
  • Goal:
    • Allow move-aggressive memory compaction when RAII is available, with minimal disruption to current functionality.

Acceptance Criteria

  • New macro is added and properly guarded.
  • CMake option -DRAII_MODE=ON switches the project to RAII mode.
  • Only minimal code changes are made to enable RAII.
  • Code quality meets expert C++ developer standards.
  • Documentation is reviewed prior to implementation.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions