clean Nitpick's wellfoundedness cache once in a while, to avoid potential memory leak
authorblanchet
Tue, 27 Oct 2009 17:53:19 +0100
changeset 33557 107f3df799f6
parent 33556 cba22e2999d5
child 33558 a2db56854b83
clean Nitpick's wellfoundedness cache once in a while, to avoid potential memory leak
doc-src/Nitpick/nitpick.tex
src/HOL/Tools/Nitpick/nitpick_hol.ML
--- a/doc-src/Nitpick/nitpick.tex	Tue Oct 27 16:52:06 2009 +0100
+++ b/doc-src/Nitpick/nitpick.tex	Tue Oct 27 17:53:19 2009 +0100
@@ -2398,11 +2398,11 @@
 & \textit{subgoal}\end{aligned}$
 \postw
 
+\let\antiq=\textrm
+
 \subsection{Registration of Coinductive Datatypes}
 \label{registration-of-coinductive-datatypes}
 
-\let\antiq=\textrm
-
 If you have defined a custom coinductive datatype, you can tell Nitpick about
 it, so that it can use an efficient Kodkod axiomatization similar to the one it
 uses for lazy lists. The interface for registering and unregistering coinductive
--- a/src/HOL/Tools/Nitpick/nitpick_hol.ML	Tue Oct 27 16:52:06 2009 +0100
+++ b/src/HOL/Tools/Nitpick/nitpick_hol.ML	Tue Oct 27 17:53:19 2009 +0100
@@ -1606,6 +1606,7 @@
                                  (tac ctxt (auto_tac (clasimpset_of ctxt))))
        #> the #> Goal.finish ctxt) goal
 
+val max_cached_wfs = 100
 val cached_timeout = Unsynchronized.ref (SOME Time.zeroTime)
 val cached_wf_props : (term * bool) list Unsynchronized.ref =
   Unsynchronized.ref []
@@ -1639,8 +1640,11 @@
                  else
                    ()
        in
-         if tac_timeout = (!cached_timeout) then ()
-         else (cached_wf_props := []; cached_timeout := tac_timeout);
+         if tac_timeout = (!cached_timeout)
+            andalso length (!cached_wf_props) < max_cached_wfs then
+           ()
+         else
+           (cached_wf_props := []; cached_timeout := tac_timeout);
          case AList.lookup (op =) (!cached_wf_props) prop of
            SOME wf => wf
          | NONE =>