Skip to content

Commit

Permalink
Issue 4134: Fixing memory leak error when using DirectEntryLogger (#4135
Browse files Browse the repository at this point in the history
)

### Motivation

When we use DirectIO and a catch up read occurs, a memory leak occurs because the ByteBuf is not released. 

Because although in the `internalReadEntry` method in `DirectEntryLogger`, even if the upper layer `fillReadAheadCache` uses the `ReferenceCountUtil.release(entry)` method in the finally block to release ByteBuf, it will still cause an exception thrown by `internalReadEntry`, and the `entryLogger.readEntry` method happens to be in try. ..catch unexpected, causing ByteBuf to not be released correctly

### Changes

Master Issue: #4134
  • Loading branch information
graysonzeng authored Jan 8, 2024
1 parent 5fc3eef commit cc1c2e0
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ private ByteBuf internalReadEntry(long ledgerId, long entryId, long location, bo
long thisEntryId = buf.getLong(8);
if (thisLedgerId != ledgerId
|| thisEntryId != entryId) {
ReferenceCountUtil.release(buf);
throw new IOException(
exMsg("Bad location").kv("location", location)
.kv("expectedLedger", ledgerId).kv("expectedEntry", entryId)
Expand Down

0 comments on commit cc1c2e0

Please sign in to comment.