@@ -8,6 +8,7 @@ use std::{env, path::PathBuf};
88use clap:: Parser ;
99pub use ext:: * ;
1010use jrsonnet_evaluator:: { error:: Result , FileImportResolver , State } ;
11+ use jrsonnet_gcmodule:: with_thread_object_space;
1112pub use manifest:: * ;
1213pub use tla:: * ;
1314pub use trace:: * ;
@@ -111,15 +112,21 @@ pub struct GcOpts {
111112 gc_collect_before_printing_stats : bool ,
112113}
113114impl GcOpts {
114- pub fn configure_global ( & self ) {
115- if !self . gc_collect_on_exit {
116- gcmodule:: set_thread_collect_on_drop ( false )
117- }
115+ pub fn stats_printer ( & self ) -> ( Option < GcStatsPrinter > , Option < LeakSpace > ) {
116+ (
117+ self . gc_print_stats . then ( || GcStatsPrinter {
118+ collect_before_printing_stats : self . gc_collect_before_printing_stats ,
119+ } ) ,
120+ ( !self . gc_collect_on_exit ) . then ( || LeakSpace { } ) ,
121+ )
118122 }
119- pub fn stats_printer ( & self ) -> Option < GcStatsPrinter > {
120- self . gc_print_stats . then ( || GcStatsPrinter {
121- collect_before_printing_stats : self . gc_collect_before_printing_stats ,
122- } )
123+ }
124+
125+ pub struct LeakSpace { }
126+
127+ impl Drop for LeakSpace {
128+ fn drop ( & mut self ) {
129+ with_thread_object_space ( |s| s. leak ( ) )
123130 }
124131}
125132
@@ -130,9 +137,9 @@ impl Drop for GcStatsPrinter {
130137 fn drop ( & mut self ) {
131138 eprintln ! ( "=== GC STATS ===" ) ;
132139 if self . collect_before_printing_stats {
133- let collected = gcmodule :: collect_thread_cycles ( ) ;
140+ let collected = jrsonnet_gcmodule :: collect_thread_cycles ( ) ;
134141 eprintln ! ( "Collected: {}" , collected) ;
135142 }
136- eprintln ! ( "Tracked: {}" , gcmodule :: count_thread_tracked( ) )
143+ eprintln ! ( "Tracked: {}" , jrsonnet_gcmodule :: count_thread_tracked( ) )
137144 }
138145}
0 commit comments