private void discardReadBytesIfNecessary ( ByteBuf buffer ) { float usedRatio = ( float ) buffer . readerIndex ( ) / buffer . capacity ( ) ; if ( usedRatio >= discardReadBytesRatio && buffer . refCnt ( ) != 0 ) { buffer . discardReadBytes ( ) ; } }
Try to discard read bytes when buffer usage reach a higher usage ratio .