The weak versions of the memoization functions use a Weak_hashtbl for the memo
table. This keeps a weak pointer to each result, and so the garbage collector
automatically removes unused results. Furthermore, stabilize
removes the table
entries whose result is unused.