---
tag: m0100
title: Free Memory
brief: Observe memory used by code
author: thinkyhead

requires: M100_FREE_MEMORY_WATCHER
group: debug

codes: [ M100 ]

notes:
  - Requires `M100_FREE_MEMORY_WATCHER`.

parameters:
  -
    tag: D
    optional: true
    description: Dump the free memory block from `__brkval` to the stack pointer
  -
    tag: F
    optional: true
    description: Return the number of free bytes in the memory pool along with other vital statistics that define the memory pool
  -
    tag: I
    optional: true
    description: Initialize the free memory pool so it can be watched and print vital statistics that define the free memory pool
  -
    tag: C
    optional: true
    description: Corrupt 'n' locations in the free memory pool and report the locations of the corruption. This is useful to check the correctness of the `M100 D` and `M100 F` commands
    values:
      -
        tag: n
        type: int

examples:

---

Use [`M100`](/docs/gcode/M100.html) for development purposes to observe how much memory (particularly stack) is being used by code. Proper AVR code should avoid use of `new`, `malloc`, etc., and instead use either pre-allocated static variables or stack.
