@@ -8,6 +8,7 @@ use std::{env, path::PathBuf};
8
8
use clap:: Parser ;
9
9
pub use ext:: * ;
10
10
use jrsonnet_evaluator:: { error:: Result , FileImportResolver , State } ;
11
+ use jrsonnet_gcmodule:: with_thread_object_space;
11
12
pub use manifest:: * ;
12
13
pub use tla:: * ;
13
14
pub use trace:: * ;
@@ -111,15 +112,21 @@ pub struct GcOpts {
111
112
gc_collect_before_printing_stats : bool ,
112
113
}
113
114
impl 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
+ )
118
122
}
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 ( ) )
123
130
}
124
131
}
125
132
@@ -130,9 +137,9 @@ impl Drop for GcStatsPrinter {
130
137
fn drop ( & mut self ) {
131
138
eprintln ! ( "=== GC STATS ===" ) ;
132
139
if self . collect_before_printing_stats {
133
- let collected = gcmodule :: collect_thread_cycles ( ) ;
140
+ let collected = jrsonnet_gcmodule :: collect_thread_cycles ( ) ;
134
141
eprintln ! ( "Collected: {}" , collected) ;
135
142
}
136
- eprintln ! ( "Tracked: {}" , gcmodule :: count_thread_tracked( ) )
143
+ eprintln ! ( "Tracked: {}" , jrsonnet_gcmodule :: count_thread_tracked( ) )
137
144
}
138
145
}
0 commit comments