From b29c19ca657c41208bf76706773c7cbc59ef38f8 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 28 Jun 2024 11:55:41 +0200 Subject: [PATCH 1/2] Remove {,get_}instances as it is causing a memory leak #287 --- src/core/QCheck2.ml | 8 +------- src/core/QCheck2.mli | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/core/QCheck2.ml b/src/core/QCheck2.ml index a0cc4e7b..1bf96d2b 100644 --- a/src/core/QCheck2.ml +++ b/src/core/QCheck2.ml @@ -1354,9 +1354,6 @@ module TestResult = struct collect_tbl: (string, int) Hashtbl.t lazy_t; stats_tbl: ('a stat * (int, int) Hashtbl.t) list; mutable warnings: string list; - mutable instances: 'a list; - (** List of instances used for this test, in no particular order. - @since 0.9 *) } let get_state {state; _} = state @@ -1391,8 +1388,6 @@ module TestResult = struct let warnings = get_warnings - let get_instances r = r.instances - let is_success r = match r.state with | Success -> true | Failed _ | Error _ | Failed_other _ -> false @@ -1763,7 +1758,6 @@ module Test = struct and check_state_input state input_tree = let Tree.Tree (input, _) = input_tree in state.handler state.test.name state.test (Collecting input); - state.res.R.instances <- input :: state.res.R.instances; collect state input; update_stats state input; let res = @@ -1835,7 +1829,7 @@ module Test = struct res = {R. state=R.Success; count=0; count_gen=0; collect_tbl=lazy (Hashtbl.create 10); - instances=[]; warnings=[]; + warnings=[]; stats_tbl= List.map (fun stat -> stat, Hashtbl.create 10) cell.stats; }; } in diff --git a/src/core/QCheck2.mli b/src/core/QCheck2.mli index 75f68ce8..ceed40e5 100644 --- a/src/core/QCheck2.mli +++ b/src/core/QCheck2.mli @@ -1610,10 +1610,6 @@ module TestResult : sig (** [get_warnings t] returns the list of warnings emitted during the test. @since 0.18 *) - val get_instances : 'a t -> 'a list - (** [get_instances t] returns the generated instances, with no guarantee on the order. - @since 0.18 *) - val is_success : _ t -> bool (** Returns true iff the state is [Success] @since 0.9 *) From 55b3f859878b94c08a4a96ff84c1c662ede728cf Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 28 Jun 2024 12:03:49 +0200 Subject: [PATCH 2/2] Add a CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbb35752..eb767a0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## NEXT RELEASE -- ... +- Remove `QCheck2.TestResult.get_instances` as retaining previous test inputs + cause memory leaks ## 0.21.3