<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.5.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSGarbageCollector/defaultCollector",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGarbageCollector(cm)defaultCollector"
  },
  "title" : "defaultCollector"
}
-->

# defaultCollector

Returns the default garbage collector.

```
+ (id) defaultCollector;
```

## Return Value

The default garbage collector for the current process. Returns `nil` if the current process is not running with garbage collection.

## Discussion

There is at most one garbage collector for Cocoa within a single process.

---

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)