Warning: This is a legacy page that is only displayed for historical reasons. I stopped developing Memcheck in 2007 because Olmar development stopped then and Memcheck was only developed for Olmar. In contrast to Olmar there exist no alternatives to Memcheck. In 2016 I updated the sources to compile with camlp5 and OCaml 4.03.
Memcheck can check at runtime whether a given value has a certain type. This is usefulMemcheck is very similar to SafeUnmarshal. I wrote Memcheck as a substitute for SafeUnmarshal when I could not longer live with the deficiencies, performance problems and the seemingly dead status of SafeUnmarshal (see this message and this message on the ocaml mailing list).
Strictly speaking Memcheck (and SafeUnmarshal) only checks if the memory representation of a value agrees with a given type. The memory representation for, e.g. 0 and None are the same, therefore checking None against the type int will succeed. Similarly a tuple can be considered as a record or an array.
Please drop me a line at hendrik@askra.de
if you are interested in Memcheck and it doesn't work out of the
box. I will then try to help out.
Download / Installation
Usage
This will generate a constant name_type_descr for
every type definition found. For parametric type definitions it
will be a function taking a type description argument for each
parameter type.
echo "open Memcheck;;" > type_descr.ml
camlp5o path_to_memcheck/generate_type_descr.cmo type_def.ml >> type_descr.ml
ocamlc -I path_to_memcheck -c type_descr.ml
open Memcheck;;
check [Channel stdout; Verbose_trace] some_value (<type_name>_type_descr arguments ...)
Comparison with SafeUnmarshal
Memcheck was partly inspired by SafeUnmarshal and shares a lot of idias with it. The most
important differances are
Memcheck does the following to ensure that every type that occurs during runtime type checking is associated with precisely one tag:
Type-constructor applications are expanded when they are met
during runtime type checking. Type-constructor applications are
always boxed in a reference cell, which gets updated once the
application is performed. Therefore, for instance, to check an
int list, the list type constructor needs
only to be applied twice: first at top level and then inside the
list type constructor.
Known Problems
Contact
Please contact me at hendrik@askra.de with anything
Memcheck related.