fix: use Weak references for CachedPath to enable proper drop#727
Merged
graphite-app[bot] merged 1 commit intomainfrom Sep 23, 2025
Conversation
Member
Author
How to use the Graphite Merge QueueAdd the label merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
This comment was marked as off-topic.
This comment was marked as off-topic.
a471b41 to
a7be55f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
- Coverage 94.68% 94.63% -0.05%
==========================================
Files 15 15
Lines 2896 2908 +12
==========================================
+ Hits 2742 2752 +10
- Misses 154 156 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a7be55f to
65a5375
Compare
Merge activity
|
Related: * oxc-project/oxc#10627 The resolver was experiencing memory leaks due to circular strong references between `CachedPath` objects. Even after the resolver was dropped, `CachedPath` instances (and their associated `PackageJson` data) remained in memory due to reference cycles created by Arc (reference-counted) pointers. The memory leak was caused by circular references in three fields of `CachedPathImpl`: 1. `parent: Option<CachedPath>` - Child paths held strong references to parent paths 2. `canonicalized: OnceLock<Result<CachedPath, ResolveError>>` - Paths held strong references to their canonicalized versions 3. `node_modules: OnceLock<Option<CachedPath>>` - Parent directories held strong references to their node_modules subdirectories These created reference cycles preventing Arc reference counts from reaching zero. Converted all fields that could create circular references to use `Weak` references: - `parent: Option<Weak<CachedPathImpl>>` - `canonicalized: OnceLock<Result<Weak<CachedPathImpl>, ResolveError>>` - `node_modules: OnceLock<Option<Weak<CachedPathImpl>>>` Updated all accessor methods to upgrade Weak references when needed: - `parent()` - Upgrades weak parent reference - `cached_node_modules()` - Stores and retrieves weak references - `canonicalize_impl()` - Stores canonicalized paths as weak references Passes `test_memory_leak_arc_cycles` that failed in the previous stack.
65a5375 to
bc9c219
Compare
This was referenced Sep 23, 2025
Merged
graphite-app bot
pushed a commit
to rolldown/rolldown
that referenced
this pull request
Sep 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related:
The resolver was experiencing memory leaks due to circular strong references between
CachedPathobjects. Even after the resolver was dropped,CachedPathinstances (and their associatedPackageJsondata) remained in memory due to reference cycles created by Arc (reference-counted) pointers.The memory leak was caused by circular references in three fields of
CachedPathImpl:parent: Option<CachedPath>- Child paths held strong references to parent pathscanonicalized: OnceLock<Result<CachedPath, ResolveError>>- Paths held strong references to their canonicalized versionsnode_modules: OnceLock<Option<CachedPath>>- Parent directories held strong references to their node_modules subdirectoriesThese created reference cycles preventing Arc reference counts from reaching zero.
Converted all fields that could create circular references to use
Weakreferences:parent: Option<Weak<CachedPathImpl>>canonicalized: OnceLock<Result<Weak<CachedPathImpl>, ResolveError>>node_modules: OnceLock<Option<Weak<CachedPathImpl>>>Updated all accessor methods to upgrade Weak references when needed:
parent()- Upgrades weak parent referencecached_node_modules()- Stores and retrieves weak referencescanonicalize_impl()- Stores canonicalized paths as weak referencesPasses
test_memory_leak_arc_cyclesthat failed in the previous stack.