<!--
{
  "documentType" : "article",
  "framework" : "Xcode",
  "identifier" : "/documentation/Xcode/deallocation-of-deallocated-memory",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Deallocation of deallocated memory"
}
-->

# Deallocation of deallocated memory

Detects attempts to free deallocated memory.

## Overview

Use this check to detect when you call `free` on deallocated memory, commonly referred to as a *double free* error. Attempting to deallocate memory more than once can result in a crash or other unpredictable behavior. Available in Xcode 7 and later.

### Deallocation of freed memory in C

In the following example, the code deallocates the `p_int` variable after the call to free its memory:

```occ
int *pointer = malloc(sizeof(int));
free(pointer);
free(pointer); // Error: free called twice with the same memory address 
```

#### Solution

Ensure that you call the `free` function just once for memory you allocate.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)