<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSObjectFinalizeCallback",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@T@JSObjectFinalizeCallback"
  },
  "title" : "JSObjectFinalizeCallback"
}
-->

# JSObjectFinalizeCallback

The callback type for finalizing an object (preparing it for garbage collection).

```
typealias JSObjectFinalizeCallback = (JSObjectRef?) -> Void
```

## Parameters

`object`

The [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) to finalize.

## Discussion

You can finalize an object on any thread.

If you name your function `Finalize`, you declare it like this:

```c
void Finalize(JSObjectRef object);
```

The system calls the finalize callback on the most-derived class first, and the least-derived class (the parent class) last.

You must not call any function that may cause a garbage collection or an allocation of a garbage collected object from within a [`JSObjectFinalizeCallback`](/documentation/JavaScriptCore/JSObjectFinalizeCallback). This includes all functions that have a [`JSContextRef`](/documentation/JavaScriptCore/JSContextRef) parameter.

---

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)