Skip to content

Commit f73ae69

Browse files
Release DocumentField instances in SearchHit.deallocate
These can consume non-trivial heap if transport messages start to queue up. Lets release them asap.
1 parent eee890a commit f73ae69

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/src/main/java/org/elasticsearch/search/SearchHit.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,14 @@ private void deallocate() {
724724
r.decRef();
725725
}
726726
SearchHit.this.source = null;
727+
clearIfMutable(documentFields);
728+
clearIfMutable(metaFields);
729+
}
730+
731+
private static void clearIfMutable(Map<String, DocumentField> fields) {
732+
if (fields instanceof HashMap<?, ?> hm) {
733+
hm.clear();
734+
}
727735
}
728736

729737
@Override

0 commit comments

Comments
 (0)