Skip to content

Commit

Permalink
fix(server): Fix memory leak when reach memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
wenlongwlli committed Oct 16, 2024
1 parent ba2302c commit 3198146
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,19 @@ private static Map<Integer, List<ShuffleBlockInfo>> decodePartitionData(ByteBuf
int lengthOfShuffleBlocks = byteBuf.readInt();
List<ShuffleBlockInfo> shuffleBlockInfoList = Lists.newArrayList();
for (int j = 0; j < lengthOfShuffleBlocks; j++) {
shuffleBlockInfoList.add(Decoders.decodeShuffleBlockInfo(byteBuf));
try {
shuffleBlockInfoList.add(Decoders.decodeShuffleBlockInfo(byteBuf));
} catch (Throwable t) {
// An OutOfDirectMemoryError will be thrown, when the direct memory reaches the limit.
// OutOfDirectMemoryError does not cause the jvm exit and cause the direct memory leak.
// Warning: Please set DIRECT_MEMORY_LIMIT to a reasonable value.
shuffleBlockInfoList.forEach(sbi -> sbi.getData().release());
partitionToBlocks.forEach(
(integer, shuffleBlockInfos) -> {
shuffleBlockInfos.forEach(sbi -> sbi.getData().release());
});
throw t;
}
}
partitionToBlocks.put(partitionId, shuffleBlockInfoList);
}
Expand Down

0 comments on commit 3198146

Please sign in to comment.