# [Adding Memory Tagging to a Dynamic Memory Allocator](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/)

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/)
- [Why Use Memory Tagging?](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/how-to-1/)
- [Implement Memory Tagging for a Dynamic Memory Allocator](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/how-to-2/)
- [Memory Tagging Changes](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/how-to-3/)
- [Preventing Mistakes By Using Memory Tagging](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/how-to-4/)
- [Memory Tagged Allocation Summary](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/how-to-5/)
- [Next Steps](https://learn.arm.com/learning-paths/laptops-and-desktops/memory-tagged-dynamic-memory-allocator/_next-steps/)

## About this Learning Path

| Skill level:      | Advanced        |
|--------------------|-----------------|
| Reading time:      | 2 hrs           |
| Last updated:      | 29 Jul 2026     |
| Author:            | David Spickett, Arm |
| Arm IP:            | [Cortex-A](https://support.arm.com/?tab=compute-ip&Product%20Type=Application%20Processors) |
| Tags:              | [Performance and Architecture](https://learn.arm.com/tag/performance-and-architecture), [Linux](https://learn.arm.com/tag/linux), [MTE](https://learn.arm.com/tag/mte), [C](https://learn.arm.com/tag/c) |

## Who is this for?

This is an advanced topic for software developers who want to learn how to use the Memory Tagging Extension (MTE) to protect dynamic memory allocations.

## What will you learn?

Upon completion of this Learning Path, you will be able to:
- Learn how to apply MTE to an existing memory allocator
- Understand how MTE can prevent common memory use errors

## Prerequisites

Before starting, you will need the following:
- A Linux computer.
- Basic knowledge of how MTE works. Refer to the [Learn about Memory Tagging Extension Learning Path](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/mte/).
- Knowledge of how a dynamic memory allocator can be implemented. Refer to the [Write a Dynamic Memory Allocator Learning Path](https://learn.arm.com/learning-paths/cross-platform/dynamic-memory-allocator/).

## Summary

You’ll add Arm MTE checks to a Linux dynamic memory allocator. You’ll enable tagged addresses and synchronous checking, update the allocator and tag helpers, and run misuse examples that trigger mismatches. You’ll trace tag setup and checks across `heap.c`, `heap.h`, `mte_utils.c`, `mte_utils.h`, and `main.c`, then inspect the resulting exceptions.

## Frequently asked questions

<details>
<summary>Which files should I modify to explore allocator and tagging behavior?</summary>
Edit `heap.c` and `heap.h` for allocator changes and `mte_utils.c` and `mte_utils.h` for tag helper logic. Use `main.c` to exercise the allocator and drive specific scenarios.
</details>

<details>
<summary>How do I run the example misuse cases that demonstrate tag faults?</summary>
Add calls in `main.c` to the example functions and rebuild the project. Each function triggers a scenario so you can observe how the MTE-enabled allocator responds.
</details>

<details>
<summary>What should I check if no tag faults occur when I expect them?</summary>
Verify that process and heap initialization that enables tagged addresses runs before any allocations. Also confirm that the example functions are called from `main.c`.
</details>

<details>
<summary>What result should I expect when there is a tag mismatch?</summary>
On access, MTE compares the pointer’s logical tag with the memory’s allocation tag and raises an exception if they differ. The demo scenarios are designed to make this behavior visible.
</details>

<details>
<summary>Which tag checking mode does the demo configure?</summary>
The initialization sets synchronous tag checking. Apply this configuration when enabling tagged addresses for the process.
</details>
