Code example for ObjectOutputStream

Methods: flush, reset, writeObject

0
        ObjectOutputStream oout = this.oout;
        if (resetInterval != 0) {
            // Resetting will prevent OOM on the receiving side. 
            writtenObjects ++;
            if (writtenObjects % resetInterval == 0) {
                oout.reset();
 
                // Also discard the byproduct to avoid OOM on the sending side. 
                buffer.discardReadBytes();
            } 
        } 
        oout.writeObject(msg);
        oout.flush();
 
        ChannelBuffer encoded = buffer.readBytes(buffer.readableBytes());
        return encoded;
    } 
 
    private ChannelBuffer buffer(ChannelHandlerContext ctx) throws Exception {
        ChannelBuffer buf = buffer.get();
        if (buf == null) {