name: duk_inspect_value proto: | void duk_inspect_value(duk_context *ctx, duk_idx_t idx); stack: | [ ... val! ... ] -> [ ... val! ... info! ] summary: |

Inspect value at idx and push an object containing Duktape specific internal information about the object. If the value stack index is invalid, pushes an object describing a "none" value.

The following table summarizes current properties. Memory byte sizes don't include any heap overhead which may vary between 0-16 bytes (or more) depending on the allocation functions being used.

PropertyDescription
type Type number matching DUK_TYPE_xxx from duktape.h.
itag Internal type tag matching internal DUK_TAG_xxx defines. Values may change between versions, and are dependent on config options and the memory layout used for tagged values internally.
hptr Heap pointer for a heap-allocated value. Points to the internal Duktape header structure related to the value type. Same value would be returned from duk_get_heapptr().
refc Reference count. Reference counts are not adjusted in any way, and include references to the value caused by the duk_inspect_value() call.
class For objects, internal class number, matches internal DUK_HOBJECT_CLASS_xxx defines.
hbytes Byte size of main heap object allocation. For some values this is the only allocation, other values have additional allocations.
pbytes Byte size of an object's property table. The property table includes a possible array part, a possible hash part, and a key/value entry part.
bcbytes Byte size of Ecmascript function bytecode (instructions, constants). Shared between all instances (closures) of a certain function template.
dbytes Byte size of the current allocation of a dynamic or external buffer. Note that external buffer allocations are not part of the Duktape heap.
esize Object entry part size in elements.
enext Object entry part first free index (= index of next property slot to be used). In practice matches number of own properties for objects that don't have uncompacted deleted keys.
asize Object array part size in elements, zero if no array part or array part has been abandoned (sparse array). May be larger or smaller than the apparent array .length.
hsize Object hash part size in elements.
tstate Internal thread state, matches internal DUK_HTHREAD_STATE_xxx defines.
variant Identifies type variants for certain types. For strings, variant 0 is an ordinary heap allocated string while variant 1 is an external string. For buffers, variant 0 is a fixed buffer, 1 is a dynamic buffer, and 2 is an external buffer.
example: | duk_inspect_value(ctx, -3); duk_get_prop_string(ctx, -1, "refc"); printf("refcount of value at -3: %ld\n", (long) duk_to_int(ctx, -1)); duk_pop_2(ctx); tags: - stack - inspect introduced: 2.0.0