about Netty cause OutOfDirectMemoryError

69 views
Skip to first unread message

you fu

unread,
Apr 14, 2019, 6:52:47 AM4/14/19
to Netty discussions
Hi , When my application occur OutOfDirectMemoryError, dump JVM memory profile.

the io.netty.channel.ChannelOutboundBuffer instance  totalPendingSize  is  13,864,807,239 , and unwritable is 1.

netty1.jpg



the server code is 
          .childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 67108864)  //16MB
          .childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 1048576) //1M 

why the totalPendingSize can increase to  13,864,807,239?


you fu

unread,
Apr 14, 2019, 6:54:21 AM4/14/19
to Netty discussions
the Netty veriosn is 4.0.42.Final 

you fu

unread,
Apr 16, 2019, 11:02:41 AM4/16/19
to Netty discussions
I read the source code and debug it .

find DefaultMessageSizeEstimator size method  

public int size(Object msg) {
if (msg instanceof ByteBuf) {
return ((ByteBuf)msg).readableBytes();
} else if (msg instanceof ByteBufHolder) {
return ((ByteBufHolder)msg).content().readableBytes();
} else {
return msg instanceof FileRegion ? 0 : this.unknownSize;
}
}


if msg is my customize msg ,the size is only 8 .

so I read the code ,and  channel config ChannelOption.MESSAGE_SIZE_ESTIMATOR,
I implement myMessageSizeEstimator use code config  
  .childOption(ChannelOption.MESSAGE_SIZE_ESTIMATOR, MyDefaultMessageSizeEstimator.DEFAULT)

is it right?

Norman Maurer

unread,
Apr 16, 2019, 1:06:51 PM4/16/19
to ne...@googlegroups.com
Yes that’s the way to go 

-- 
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/81f1e04a-22f8-42a7-b8c4-50763b5062cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

you fu

unread,
Apr 17, 2019, 1:06:57 AM4/17/19
to Netty discussions

thank you for reply.
To unsubscribe from this group and stop receiving emails from it, send an email to ne...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages