File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ use std:: sync:: Arc ;
2+
3+ use crate :: Resolver ;
4+
5+ /// Test to prove memory leak in `CachedPath` Arc cycles
6+ #[ test]
7+ fn test_memory_leak_arc_cycles ( ) {
8+ let f = super :: fixture_root ( ) . join ( "misc" ) ;
9+
10+ let resolver = Resolver :: default ( ) ;
11+
12+ let path = resolver. cache . value ( & f) ;
13+
14+ resolver. resolve ( & f, "package-json-nested" ) . unwrap ( ) ;
15+
16+ // Populated cache - path is now owned in multiple places.
17+ assert_eq ! ( Arc :: strong_count( & path. 0 ) , 4 ) ;
18+
19+ // Drop the resolver.
20+ drop ( resolver) ;
21+
22+ // All Arcs must be dropped, leaving the original count of 1.
23+ assert_eq ! ( Arc :: strong_count( & path. 0 ) , 1 ) ;
24+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ mod imports_field;
1111mod incorrect_description_file;
1212mod main_field;
1313mod memory_fs;
14+ mod memory_leak;
1415mod missing;
1516mod module_type;
1617mod package_json;
You can’t perform that action at this time.
0 commit comments