RbxStu V3 Docs
  • Welcome
  • Information
    • Engine Information
      • Luau API Security
  • Stunc
    • Overview
    • Connections
    • Filesystem
      • readfile
      • writefile
      • appendfile
      • isfile
      • isfolder
      • listfiles
      • makefolder
      • delfile
      • delfolder
      • loadfile
      • dofile
  • Memory
    • getgc
    • reference_object
    • unreference_object
    • get_gc_threshold
  • Closures
    • isunhookable
    • makeunhookable
    • ishooked
    • restorefunction
    • hookfunction
    • hookmetamethod
    • isourclosure
    • iscclosure
    • islclosure
    • clonefunction
    • newcclosure
    • newlclosure
    • loadstring
Powered by GitBook
On this page
  1. Memory

unreference_object

Overview of the unreference_object function.

Function definition
function unreference_object(ref: number): ()

Remarks

Utilising this function to unreference objects that do not belong to you or have not been created using reference_objectmay lead to errors. Do not attempt to unreference any functions, threads, etc., that are NOT your responsibility that are present on the Luau Registry, as they may be a connection or something significant, and rewriting them may potentially lead to undefined behaviour from Roblox itself, as it potentially NEVER expected something similar to happen.

The refargument is an integer, not a floating point number.

High-Level Overview

unreference_object will unreference the provided index in the Luau Registry, allowing the object that was referenced there to be collected once again.

Low-Level Overview

We make use of the lua_reffunction, and reference the element at the top of the luau stack once we validate that it is a collectable type, after which we return the index into the Luau Registry it provides back to the caller. To allow the object to be freed, use unreference_object.

Previousreference_objectNextget_gc_threshold

Last updated 4 months ago