@@ -15,7 +15,7 @@ use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
1515use self_cell:: self_cell;
1616use smallvec:: SmallVec ;
1717
18- use oxc_allocator:: Allocator ;
18+ use oxc_allocator:: { Allocator , AllocatorGuard , AllocatorPool } ;
1919use oxc_diagnostics:: { DiagnosticSender , DiagnosticService , Error , OxcDiagnostic } ;
2020use oxc_parser:: { ParseOptions , Parser } ;
2121use oxc_resolver:: Resolver ;
@@ -42,6 +42,8 @@ pub struct Runtime<'l> {
4242 resolver : Option < Resolver > ,
4343
4444 pub ( super ) file_system : Box < dyn RuntimeFileSystem + Sync + Send > ,
45+
46+ allocator_pool : AllocatorPool ,
4547}
4648
4749/// Output of `Runtime::process_path`
@@ -95,7 +97,7 @@ unsafe impl Send for ModuleContent {}
9597
9698struct ModuleContentOwner {
9799 source_text : String ,
98- allocator : Allocator ,
100+ allocator : AllocatorGuard ,
99101}
100102
101103/// source text and semantic for each source section. They are in the same order as `ProcessedModule.section_module_records`
@@ -160,11 +162,16 @@ impl RuntimeFileSystem for OsFileSystem {
160162}
161163
162164impl < ' l > Runtime < ' l > {
163- pub ( super ) fn new ( linter : & ' l Linter , options : LintServiceOptions ) -> Self {
165+ pub ( super ) fn new (
166+ linter : & ' l Linter ,
167+ allocator_pool : AllocatorPool ,
168+ options : LintServiceOptions ,
169+ ) -> Self {
164170 let resolver = options. cross_module . then ( || {
165171 Self :: get_resolver ( options. tsconfig . or_else ( || Some ( options. cwd . join ( "tsconfig.json" ) ) ) )
166172 } ) ;
167173 Self {
174+ allocator_pool,
168175 cwd : options. cwd ,
169176 paths : options. paths . iter ( ) . cloned ( ) . collect ( ) ,
170177 linter,
@@ -771,7 +778,9 @@ impl<'l> Runtime<'l> {
771778 } ;
772779 let mut records = SmallVec :: < [ Result < ResolvedModuleRecord , Vec < OxcDiagnostic > > ; 1 ] > :: new ( ) ;
773780 let mut module_content: Option < ModuleContent > = None ;
774- let allocator = Allocator :: default ( ) ;
781+
782+ let allocator = self . allocator_pool . get ( ) ;
783+
775784 if self . paths . contains ( path) {
776785 module_content =
777786 Some ( ModuleContent :: new ( ModuleContentOwner { source_text, allocator } , |owner| {
0 commit comments