mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
They can be close()d explicitly with close-file-descriptor, and will close() on gc, but only explicitly closing the last port on them will close the fileno. Notably needed for network sockets where we open separate input and output ports on the same socket.
24 lines
889 B
Scheme
24 lines
889 B
Scheme
|
|
;;> Utilities for gathering statistics on the heap. Just measuring
|
|
;;> runtime memory usage doesn't give a good idea of how to optimize
|
|
;;> that usage, so this module is provided for profiling.
|
|
|
|
;;> \procedure{(heap-stats)}
|
|
|
|
;;> Returns an alist summarizing all heap allocated objects. The
|
|
;;> \var{car} of each cell is the type-name, and the \var{cdr} is the
|
|
;;> count of objects of that type in the heap. Garbage is collected
|
|
;;> before the counts are taken.
|
|
|
|
;;> \procedure{(heap-dump [depth])}
|
|
|
|
;;> Returns the same value as \scheme{(heap-stats)}, but also prints
|
|
;;> all objects on the heap as it runs. \var{depth} indicates the
|
|
;;> printing depth for compound objects and defaults to 1.
|
|
|
|
;;> These functions just return \scheme{'()} when using the Boehm GC.
|
|
|
|
(define-library (chibi heap-stats)
|
|
(export heap-stats heap-dump)
|
|
(import (chibi))
|
|
(include-shared "heap-stats"))
|