Skip to content

Commit 88d4704

Browse files
authored
Fixes memory leak in BytesRefLongBlockHash (elastic#137050)
1 parent 5ea782c commit 88d4704

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/changelog/137050.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 137050
2+
summary: Fixes memory leak in `BytesRefLongBlockHash`
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 137021

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/BytesRefLongBlockHash.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,15 @@ public Block[] getKeys() {
161161
}
162162
// TODO: make takeOwnershipOf work?
163163
BytesRefArray bytes = BytesRefArray.deepCopy(bytesHash.hash.getBytesRefs());
164+
BytesRefVector dict = null;
165+
164166
try {
165-
var dict = blockFactory.newBytesRefArrayVector(bytes, Math.toIntExact(bytes.size()));
167+
dict = blockFactory.newBytesRefArrayVector(bytes, Math.toIntExact(bytes.size()));
166168
bytes = null; // transfer ownership to dict
167169
k1 = new OrdinalBytesRefBlock(ordinals.build(), dict);
170+
dict = null; // transfer ownership to k1
168171
} finally {
169-
Releasables.closeExpectNoException(bytes);
172+
Releasables.closeExpectNoException(bytes, dict);
170173
}
171174
k2 = longs.build();
172175
} finally {

0 commit comments

Comments
 (0)