GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove reference to parent in recycled buffers for leak detection (#1… · netty/netty@fe932ff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • buffer/src/main/java/io/netty/buffer
    • AbstractPooledDerivedByteBuf.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎buffer/src/main/java/io/netty/buffer/AbstractPooledDerivedByteBuf.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/AbstractPooledDerivedByteBuf.java
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.netty.buffer;
1818

19+
import io.netty.util.IllegalReferenceCountException;
1920
import io.netty.util.Recycler.EnhancedHandle;
2021
import io.netty.util.internal.ObjectPool.Handle;
2122

@@ -51,6 +52,10 @@ final void parent(ByteBuf newParent) {
5152

5253
@Override
5354
public final AbstractByteBuf unwrap() {
55+
AbstractByteBuf rootParent = this.rootParent;
56+
if (rootParent == null) {
57+
throw new IllegalReferenceCountException();
58+
}
5459
return rootParent;
5560
}
5661

@@ -83,6 +88,8 @@ protected final void deallocate() {
8388
// otherwise it is possible that the same AbstractPooledDerivedByteBuf is again obtained and init(...) is
8489
// called before we actually have a chance to call release(). This leads to call release() on the wrong parent.
8590
ByteBuf parent = this.parent;
91+
// Remove references to parent and root so that they can be GCed for leak detection [netty/netty#14247]
92+
this.parent = this.rootParent = null;
8693
recyclerHandle.unguardedRecycle(this);
8794
parent.release();
8895
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.