package objsize

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Compute memory usage of OCaml heap values (by recursively inspecting runtime representation)

type tag_info = {
  1. tag : int;
    (*

    heap value tag

    *)
  2. count : int;
    (*

    number of values with this tag (eq. words used for headers)

    *)
  3. words : int;
    (*

    heap words used for data

    *)
}
type info = {
  1. data : int;
  2. headers : int;
  3. depth : int;
  4. tags : tag_info array;
    (*

    counts grouped by tags

    • since 0.17
    *)
}

Information gathered while walking through values.

val objsize : 'a -> info

Returns information for first argument.

val objsize_limit : int -> 'a -> info

objsize_limit limit v

  • returns

    memory usage information for v. limit limits the maximum depth to follow (to prevent excess stack usage). If maximum depth is reached during heap traversal then the returned result may be less than actual. One can detect this situation by comparing returned depth against the limit.

  • since 0.17
val size_with_headers : info -> int

Calculate size in bytes

val size_without_headers : info -> int
val objsize_roots : unit -> info

Walk through all the roots and return information for the whole heap.

  • since 0.17
val objsize_roots_limit : int -> info

Walk through all the roots and return information for the whole heap. Integer parameter limits the maximum depth to follow (to prevent excess stack usage). If maximum depth is reached during heap traversal then the returned result may be less than actual. One can detect this situation by comparing returned depth against the limit.

  • since 0.17
val sub : ?tweak:bool -> info -> info -> info

sub next base calculate next - base, i.e. the changes from base to next.

  • parameter tweak

    account for the memory occupied by one info structure, default true

  • since 0.17
val string_of_tag : int -> string
  • returns

    human readable name for the tag number

  • since 0.17
val show_info : ?map:(int -> string) -> info -> string
  • returns

    human readable representation of memory usage in general

  • parameter map

    convert number of words to string

  • since 0.17
val show_tags : ?map:(int -> string) -> info -> string list
  • returns

    human readable representation of memory usage grouped by tags

  • parameter map

    convert number of words to string

  • since 0.17
OCaml

Innovation. Community. Security.