---
title: Deallocation of nonallocated memory
framework: xcode
role: article
role_heading: Article
path: xcode/deallocation-of-nonallocated-memory
---

# Deallocation of nonallocated memory

Detects attempts to free nonallocated memory.

## Overview

Overview Use this check to detect when you call free on memory that you don’t allocate using malloc. Attempting to deallocate nonallocated memory can result in a crash. Available in Xcode 7 and later. Deallocation of a stack variable in C In the following example, the value variable allocates on the stack, and deallocates when the function exits, so calling free on it is incorrect: int value = 42; free(&value); // Error: free called on stack allocated variable Solution Don’t call the free function on variables that you allocate on the stack.

## See Also

### Address Sanitizer

- [Use of deallocated memory](xcode/use-of-deallocated-memory.md)
- [Deallocation of deallocated memory](xcode/deallocation-of-deallocated-memory.md)
- [Use of stack memory after function return](xcode/use-of-stack-memory-after-function-return.md)
- [Use of out-of-scope stack memory](xcode/use-of-out-of-scope-stack-memory.md)
- [Overflow and underflow of buffers](xcode/overflow-and-underflow-of-buffers.md)
- [Overflow of C++ containers](xcode/overflow-of-c-containers.md)
