[][src]Module jlrs::frame

Frames ensure Julia's garbage collector (GC) is properly managed.

Julia data is freed by its GC when it's not in use. You will need to use a frame to do things like calling Julia functions, creating new values, and accessing modules; this ensures the values created in a specific frame are protected from garbage collection until that frame goes out of scope.

Frames can be nested, the two frame types that currently exist can be freely mixed. The main difference between the two is that a StaticFrame is created with a definite capacity, while a DynamicFrame will dynamically grow its capacity whenever a value is created or a function is called. A StaticFrame is more efficient, a DynamicFrame is easier to use. Creating a nested frame takes no space in the current frame.

Frames have two lifetimes, 'base and 'frame. The former is used to allow global values, like modules and functions defined in them, to be freely used across frames; the only restriction is that you can't return them from the base frame that was created through Julia::frame or Julia::dynamic_frame. The latter is used by data that is only valid until its frame goes out of scope, as a result values can only be used when they're guaranteed to be protected from garbage collection.

Most functionality that frames implement is defined in the Frame trait.

Structs

DynamicFrame

A DynamicFrame is a frame that has a dynamic number of slots on the GC stack. With some exceptions, creating new Values and calling them require one slot each. A DynamicFrame acquires a new slot every time one is needed. See the documentation in the value module for more information about the costs. You get access to a DynamicFrame by calling Julia::dynamic_frame or Frame::dynamic_frame, most of their functionality is defined in the Frame trait.

Output

An Output is a slot on the GC stack in the frame that was used to create it. It can be used to extend the lifetime of the result of a function call to the Output's lifetime. You can create an output by calling Frame::output.

StaticFrame

A StaticFrame is a frame that has a definite number of slots on the GC stack. With some exceptions, creating new Values and calling them require one slot each. Rather than using new slots on the GC stack when a slot is needed, a StaticFrame uses the slots it acquired on creation. See the documentation in the value module for more information about the costs. You get access to a StaticFrame by calling Julia::frame or Frame::frame, most of their functionality is defined in the Frame trait.