spark任务在集群跑一段时间大概在10h左右后报错掉线。ERROR util.ResourceLeakDetector: LEAK: ByteBuf.release()
![](https://img2018.cnblogs.com/blog/1358122/201812/1358122-20181231114338872-843346139.png)
ERROR util.ResourceLeakDetector: LEAK: ByteBuf.release() was not called before it's garbage-collected. Enable advanced leak reporting to find out where the leak occurred. To enable advanced leak reporting, specify the JVM option '-Dio.netty.leakDetection.level=advanced' or call ResourceLeakDetector.setLevel() See http://netty.io/wiki/reference-counted-objects.html for more information.
使用下面的方法手动释放直接缓冲区:
ReferenceCountUtil.releaseLater(Unpooled.directBuffer(512));