# js Provides functions for introspecting and configuring the QuickJS runtime engine. Includes debug info, memory usage, GC controls, code evaluation, etc. ### cycle_hook(callback) function or undefined to remove the callback. Register or remove a hook function that QuickJS calls once per execution cycle. If the callback is set, it receives a single argument (an optional object/value describing the cycle). If callback is undefined, the hook is removed. **callback**: A function to call each time QuickJS completes a "cycle" (internal VM loop), **Returns**: None ### dump_shapes() function Use this for internal debugging of object shapes. **Returns**: A debug string describing the internal shape hierarchy used by QuickJS. ### dump_atoms() function known by QuickJS. Helpful for diagnosing memory usage or potential key collisions. **Returns**: A debug string listing all currently registered atoms (internal property keys/symbols) ### dump_class() function Shows how many objects of each class exist, useful for advanced memory or performance profiling. **Returns**: A debug string describing the distribution of JS object classes in the QuickJS runtime. ### dump_objects() function useful for debugging memory leaks or object lifetimes. **Returns**: A debug string listing certain internal QuickJS objects and their references, ### dump_type_overheads() function Displays memory usage breakdown for different internal object types. **Returns**: A debug string describing the overheads for various JS object types in QuickJS. ### stack_info() function Internal debugging utility to examine call stack details. **Returns**: An object or string describing the runtime's current stack usage and capacity. ### calc_mem(value) function Compute the approximate size of a single JS value in memory. This is a best-effort estimate. **value**: A JavaScript value to analyze. **Returns**: Approximate memory usage (in bytes) of that single value. ### mem() function including total allocated bytes, object counts, and more. Retrieve an overview of the runtime’s memory usage. **Returns**: An object containing a comprehensive snapshot of memory usage for the current QuickJS runtime, ### mem_limit(bytes) function Set the upper memory limit for the QuickJS runtime. Exceeding this limit may cause operations to fail or throw errors. **bytes**: The maximum memory (in bytes) QuickJS is allowed to use. **Returns**: None ### gc_threshold(bytes) function Set the threshold (in bytes) for QuickJS to perform an automatic GC pass when memory usage surpasses it. **bytes**: The threshold (in bytes) at which the engine triggers automatic garbage collection. **Returns**: None ### max_stacksize(bytes) function Set the maximum stack size for QuickJS. If exceeded, the runtime may throw a stack overflow error. **bytes**: The maximum allowed stack size (in bytes) for QuickJS. **Returns**: None ### memstate() function Gives a quick overview of the memory usage, including malloc size and other allocations. **Returns**: A simpler memory usage object (malloc sizes, etc.) for the QuickJS runtime. ### gc() function Force an immediate, full garbage collection pass, reclaiming unreachable memory. **Returns**: None ### eval(src, filename) function Execute a string of JavaScript code in the current QuickJS context. **src**: A string of JavaScript source code to evaluate. **filename**: (Optional) A string for the filename or label, used in debugging or stack traces. **Returns**: The result of evaluating the given source code.