Commit d29add0
committed
fix: release references to completed stage logics in GraphInterpreter
Motivation:
GraphInterpreter retains strong references to completed stage logics in
the logics array, preventing garbage collection even after stages have
finished. This is especially problematic for long-running fused
interpreters that host subfused shells, where completed initial stages
remain referenced for the lifetime of the actor. Additionally,
Connection objects retain strong references to handler objects
(inHandler/outHandler), further preventing GC of completed stage logics.
Modification:
- afterStageHasRun now scans ALL logics for completed stages instead of
only checking the single activeStage. This ensures stages that complete
without being activeStage (e.g., boundary stages calling complete(),
cascading completions) are properly finalized and released.
- finish() and afterStageHasRun null connection handlers (inHandler/
outHandler) for finalized stages, breaking handler-to-logic reference
chains to enable garbage collection.
- toSnapshot handles null logics gracefully with <completed> placeholder
and uses connection.inOwner.stageId for positional indexing instead of
identity-based map lookups that fail with NPE on null logics.
- inLogicName/outLogicName debug methods guard against null logics.
- finish() sets logics(i) = null after finalizing each stage.
- Fix GraphStageLogicSpec "not double-terminate" test to save logic
references before execute() since afterStageHasRun now releases
completed logics.
Result:
Completed stage logics are properly finalized and released for GC
during normal stream execution (not just in finish()), reducing memory
retention in long-running fused interpreters.
Tests:
- stream-tests/testOnly GraphInterpreterSpec: 13/13 passed (includes 2 new regression tests)
- stream-tests/testOnly GraphStageLogicSpec: 17/17 passed
- stream-tests/testOnly InterpreterSpec+LifecycleInterpreterSpec+InterpreterSupervisionSpec+GraphInterpreterFailureModesSpec: 54/54 passed
References:
None - memory leak fix1 parent 8a09821 commit d29add0
679 files changed
Lines changed: 5016 additions & 7395 deletions
File tree
- .github/workflows
- actor-testkit-typed/src
- main/scala/org/apache/pekko/actor/testkit/typed
- internal
- javadsl
- scaladsl
- test
- java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl
- scala
- docs/org/apache/pekko/actor/testkit/typed/scaladsl
- org/apache/pekko/actor/testkit/typed/scaladsl
- actor-tests/src/test
- scala-3/org/apache/pekko/util
- scala/org/apache/pekko
- actor
- dispatch
- io
- dns
- pattern
- serialization
- util
- actor-typed-tests/src/test
- java
- jdocs/org/apache/pekko/typed
- org/apache/pekko/actor/typed/eventstream
- scala-3/docs/org/apache/pekko/typed
- scala
- docs/org/apache/pekko/typed
- extensions
- org/apache/pekko/actor/typed
- delivery
- internal
- receptionist
- scaladsl
- actor-typed/src/main
- scala-3/org/apache/pekko/actor/typed/internal/receptionist
- scala/org/apache/pekko/actor/typed
- delivery
- internal
- eventstream
- internal
- adapter
- jfr
- receptionist
- routing
- javadsl
- receptionist
- scaladsl
- adapter
- actor/src/main
- resources
- scala-3/org/apache/pekko/util
- scala/org/apache/pekko
- actor
- dungeon
- setup
- dispatch
- event
- io
- japi
- pattern
- internal
- serialization
- util
- bench-jmh/src/main/scala/org/apache/pekko
- actor/typed
- remote/artery
- stream
- io
- util
- cluster-metrics/src/main
- java/org/apache/pekko/cluster/metrics/protobuf/msg
- scala/org/apache/pekko/cluster/metrics
- protobuf
- cluster-sharding-typed/src
- main
- java/org/apache/pekko/cluster/sharding/typed/internal/protobuf
- mima-filters/2.0.x.backwards.excludes
- scala/org/apache/pekko/cluster/sharding/typed
- delivery
- internal
- internal
- testkit
- javadsl
- scaladsl
- multi-jvm/scala/org/apache/pekko/cluster/sharding/typed/delivery
- test
- java/jdocs
- delivery
- org/apache/pekko/cluster/sharding/typed
- scala
- docs/org/apache/pekko/cluster/sharding/typed
- org/apache/pekko/cluster/sharding
- typed
- delivery
- internal
- scaladsl
- cluster-sharding/src
- main
- java/org/apache/pekko/cluster/sharding/protobuf/msg
- mima-filters/2.0.x.backwards.excludes
- resources
- scala/org/apache/pekko/cluster/sharding
- internal/jfr
- multi-jvm/scala/org/apache/pekko/cluster/sharding
- test/scala/org/apache/pekko/cluster/sharding
- cluster-tools/src/main
- java/org/apache/pekko/cluster
- client/protobuf/msg
- pubsub/protobuf/msg
- scala/org/apache/pekko/cluster
- client
- singleton
- cluster-typed/src
- main
- java/org/apache/pekko/cluster/typed/internal/protobuf
- scala-3/org/apache/pekko/cluster/typed/internal/receptionist
- scala/org/apache/pekko/cluster
- ddata/typed
- internal
- javadsl
- scaladsl
- typed
- internal
- delivery
- receptionist
- test
- java/jdocs/org/apache/pekko/cluster/typed
- scala
- docs/org/apache/pekko/cluster/typed
- org/apache/pekko/cluster/typed
- cluster/src
- main
- java/org/apache/pekko/cluster/protobuf/msg
- scala/org/apache/pekko/cluster
- sbr
- multi-jvm/scala/org/apache/pekko/cluster
- test/scala/org/apache/pekko/cluster
- coordination/src/main/scala/org/apache/pekko/coordination/lease/scaladsl
- discovery/src
- main/scala/org/apache/pekko/discovery
- test/scala/org/apache/pekko/discovery/dns
- distributed-data/src
- main
- java/org/apache/pekko/cluster/ddata/protobuf/msg
- scala-3/org/apache/pekko/cluster/ddata
- scala/org/apache/pekko/cluster/ddata
- protobuf
- multi-jvm/scala/org/apache/pekko/cluster/ddata
- test/scala/org/apache/pekko/cluster/ddata
- docs/src
- main
- java/docs
- ddata/protobuf/msg
- persistence/proto
- paradox
- discovery
- release-notes
- stream
- operators
- Source-or-Flow
- typed
- test
- java/jdocs
- actor
- fsm
- typed
- cluster/singleton
- dispatcher
- event
- extension
- future
- io
- japi
- persistence/testkit
- routing
- serialization
- sharding
- stream/operators
- source
- typed/tutorial_1
- scala/docs
- actor
- ddata
- protobuf
- event
- io
- persistence
- serialization
- stream
- cookbook
- operators
- sourceorflow
- source
- multi-node-testkit/src/main
- java/org/apache/pekko/remote/testconductor
- scala/org/apache/pekko/remote
- testconductor
- testkit
- osgi/src
- main/scala/org/apache/pekko/osgi
- test/scala/org/apache/pekko/osgi
- persistence-query/src/main
- java/org/apache/pekko/persistence/query/internal/protobuf
- scala/org/apache/pekko/persistence/query
- internal
- journal/leveldb
- typed
- persistence-tck/src/main/scala/org/apache/pekko/persistence/journal
- persistence-testkit/src/main/scala/org/apache/pekko/persistence/testkit
- internal
- javadsl
- query/scaladsl
- scaladsl
- persistence-typed-tests/src/test
- java/org/apache/pekko/persistence/typed/state/javadsl
- scala
- docs/org/apache/pekko/persistence/typed
- org/apache/pekko/persistence/typed
- scaladsl
- state/scaladsl
- persistence-typed/src
- main
- java/org/apache/pekko/persistence/typed/serialization
- mima-filters/2.0.x.backwards.excludes
- scala/org/apache/pekko/persistence/typed
- crdt
- delivery
- internal
- javadsl
- scaladsl
- serialization
- state
- internal
- javadsl
- scaladsl
- test
- java/jdocs/org/apache/pekko/persistence/typed
- scala
- docs/org/apache/pekko/persistence/typed
- org/apache/pekko/persistence/typed
- internal
- scaladsl
- persistence/src
- main
- java/org/apache/pekko/persistence/serialization
- scala-2/org/apache/pekko/persistence
- scala-3/org/apache/pekko/persistence
- scala/org/apache/pekko/persistence
- journal
- serialization
- state
- test/scala/org/apache/pekko/persistence
- journal
- serialization
- state/exception
- project
- remote-tests/src/test/java/org/apache/pekko/remote/artery/protobuf
- remote/src
- main
- java/org/apache/pekko/remote
- mima-filters/2.0.x.backwards.excludes
- resources
- scala/org/apache/pekko/remote
- artery
- aeron
- compress
- tcp/ssl
- serialization
- test
- java/org/apache/pekko/remote
- protobuf/v3
- scala/org/apache/pekko/remote
- artery
- tcp/ssl
- classic
- serialization
- serialization-jackson3/src/main/scala/org/apache/pekko/serialization/jackson3
- serialization-jackson/src/main/scala/org/apache/pekko/serialization/jackson
- slf4j/src/main/scala/org/apache/pekko/event/slf4j
- stream-testkit/src
- main/scala/org/apache/pekko/stream/testkit
- test/scala/org/apache/pekko/stream
- impl/fusing
- testkit
- stream-tests-tck/src/test/scala/org/apache/pekko/stream/tck
- stream-tests/src/test
- java/org/apache/pekko/stream/javadsl
- scala/org/apache/pekko/stream
- impl
- fusing
- io
- compression
- scaladsl
- stream-typed-tests/src/test/scala/org/apache/pekko/stream
- stream-typed/src/test/scala/docs/org/apache/pekko/stream/typed
- stream/src/main
- java/org/apache/pekko/stream
- resources
- scala/org/apache/pekko/stream
- impl
- fusing
- io
- streamref
- javadsl
- scaladsl
- serialization
- stage
- testkit/src
- main/scala/org/apache/pekko/testkit
- javadsl
- test/scala/org/apache/pekko/testkit
- metrics/reporter
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
0 commit comments