cpp-memory-management

Manage C++ memory ownership and lifetime issues in embedded automotive code on Linux, QNX, and Android NDK.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/Binh230199/ai --skill cpp-memory-management
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cpp-memory-management
Source: https://github.com/Binh230199/ai/tree/main/.github/skills/cpp-memory-management
Command: npx skills add https://github.com/Binh230199/ai --skill cpp-memory-management

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps prevent leaks, dangling pointers, double deletes, use-after-free bugs, and unsafe heap usage in C++ code that must stay reliable in embedded automotive systems.

Core Features & Use Cases

  • Ownership design: Define clear lifetime rules for classes, subsystems, and interfaces using Rule of Zero and Rule of Five practices.
  • Smart pointer guidance: Choose between unique_ptr, shared_ptr, and weak_ptr to express ownership correctly and avoid cycles.
  • RAII and safety patterns: Wrap file handles, locks, buffers, and other resources so cleanup happens automatically and deterministically.
  • Real-time memory control: Reduce or eliminate heap allocation in performance-critical Linux, QNX, and Android NDK paths.
  • Debugging and audit support: Detect memory defects with AddressSanitizer and review code against MISRA-oriented memory rules.
  • Use case: Review an IVI or HUD module, identify raw pointer misuse, and refactor it into safer, allocation-aware C++.

Quick Start

Ask for a review of a C++ class or module and request ownership, lifetime, RAII, and smart pointer recommendations for embedded automotive memory safety.

Frequently Asked Questions about cpp-memory-management

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce RAII and the Rule of Zero when refactoring C++ code for memory safety?▼

Enforce RAII and the Rule of Zero by wrapping resources in classes that manage their own lifetimes, allowing automatic and deterministic cleanup without manual memory handling in embedded automotive C++ systems.

What is the best way to choose between unique_ptr, shared_ptr, and weak_ptr for C++ ownership design?▼

Choose unique_ptr for exclusive ownership, shared_ptr for shared lifetimes, and weak_ptr to break reference cycles, ensuring clear C++ memory ownership and preventing dangling pointers.

How do I eliminate heap allocations in real-time C++ paths on Linux, QNX, and Android NDK?▼

Eliminate heap allocations in real-time C++ paths by applying zero-allocation hot path patterns and deterministic RAII cleanup tailored for embedded automotive environments on Linux, QNX, and Android NDK.

Can I use AddressSanitizer to audit C++ modules for use-after-free and MISRA memory safety violations?▼

Use AddressSanitizer to detect use-after-free, leaks, and unsafe heap usage, and review your embedded automotive C++ code against MISRA-aligned memory safety practices for comprehensive debugging and audit support.

When should I use weak references to prevent smart pointer cycles in C++ automotive subsystems?▼

Use weak references like weak_ptr when shared ownership creates reference cycles in C++ automotive subsystems, preventing memory leaks by allowing observation of objects without extending their lifetimes.