Contents

JSValueProtect(_:_:)

Protects a JavaScript value from garbage collection.

Declaration

func JSValueProtect(_ ctx: JSContextRef!, _ value: JSValueRef!)

Parameters

  • ctx:

    The execution context to use.

  • value:

    The Jsvalueref to protect.

Discussion

Use this method when you want to store a JSValueRef in a global or on the heap, where the garbage collector can’t discover your reference to it.

You can protect a value multiple times and must unprotect it an equal number of times before it becomes eligible for garbage collection.

See Also

Supporting Garbage Collection