<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/dealloc",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)dealloc"
  },
  "title" : "dealloc"
}
-->

# dealloc

Deallocates the memory occupied by the receiver.

```
- (void) dealloc;
```

## Discussion

Subsequent messages to the receiver may generate an error indicating that a message was sent to a deallocated object (provided the deallocated memory hasn’t been reused yet).

You override this method to dispose of resources other than the object’s instance variables, for example:

```objc
- (void)dealloc {
    free(myBigBlockOfMemory);
}
```

In an implementation of `dealloc`, do not invoke the superclass’s implementation. You should try to avoid managing the lifetime of limited resources such as file descriptors using `dealloc`.

You never send a [`dealloc`](/documentation/ObjectiveC/NSObject-swift.class/dealloc) message directly. Instead, an object’s `dealloc` method is invoked by the runtime. See [Advanced Memory Management Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html#//apple_ref/doc/uid/10000011i) for more details.

### Special Considerations

When not using ARC, your implementation of `dealloc` must invoke the superclass’s implementation as its last instruction.

---

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)