Skip to content

Conversation

@TheBlueMatt
Copy link
Contributor

Based on lightningdevkit/rust-lightning#4294, basically, but the first fix should probably get backported to 0.7 as it fixes the issue for RGS ldk-node instances even though we'll have to wait for an LDK update to fix the issue for P2P gossip instances.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Dec 31, 2025

👋 Hi! This PR is now in draft status.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

`LiquiditySource` takes a reference to our `PeerManager` but the
`PeerManager` holds an indirect reference to the `LiquiditySource`.
As a result, after our `Node` instance is `stop`ped and the `Node`
`drop`ped, much of the node's memory will stick around, including
the `NetworkGraph`.

Here we fix this issue by using `Weak` pointers, though note that
there is another issue caused by LDK's gossip validation API.
LDK's gossip validation API basically forced us to have a circular
`Arc` reference, leading to memory leaks after `drop`ping an
instance of `Node`. This is fixed upstream in LDK PR #4294 which we
update to here.
Due to two circular `Arc` references, after `stop`ping and
`drop`ping the `Node` instance the bulk of ldk-node's memory (in
the form of the `NetworkGraph`) would hang around. Here we add a
test for this in our integration tests, checking if the
`NetworkGraph` (as a proxy for other objects held in reference by
the `PeerManager`) hangs around after `Node`s are `drop`ped.
@TheBlueMatt TheBlueMatt force-pushed the 2025-12-circular-arc-refs branch from 58ab500 to 05d7a7d Compare December 31, 2025 20:19
@TheBlueMatt
Copy link
Contributor Author

Note that this is (obviously) blocked on landing the upstream LDK PR.

@TheBlueMatt TheBlueMatt marked this pull request as draft December 31, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants