package offheap

  1. Overview
  2. Docs
Copies OCaml objects out of the OCaml heap

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.0.tar.gz
md5=01a952675d34ac6ec8241710edc951fe

Description

A copy of OCaml objects is moved to memory managed by malloc and free, out of the reach of the GC. If the objects are very large, performance can be improved as the traversal of large live objects does not slow the GC down.

Published: 11 Sep 2018

README

Offheap

offheap moves copies of OCaml values off the heap into memory managed by malloc and free, allowing them to be manually managed and reclaimed. Moving large objects off the heap can potentially improve performance as they are not reachable by the garbage collector, avoiding expensive traversals.

Interface

  • val copy : 'a -> 'a t

Creates a copy of an object, returning a handle to it. The handle is required to free the object. The old value is still usable.

  • val get : 'a t -> 'a

Returns a reference to the copied object from the handle.

  • val free : 'a t -> unit

Frees the off-heap memory. All references to the copied object are invalid from this point onwards.

Limitations

The object to be copied cannot reference non-Ocaml values (Custom_tag or Abstract_tag).

Acknowledgement

The implementation was inspired by the iterative traversal implemented in the Obj module of the OCaml runtime. This library was inspired by the existing ancient library, which is unable to handle large objects because of recursive traversals.

License

The code is published under the MIT License.

Dependencies (2)

  1. dune
  2. ocaml >= "4.07.0" & < "5.0.0"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.