public abstract ByteBuf duplicate()
readerIndex or writerIndex of this buffer.The reader and writer marks will not be duplicated. Also be aware that this method will NOT call retain() and so the reference count will NOT be increased.
slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.--
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/4c93f31c-a1f0-48be-94ef-b7cda094e2c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
... so something like this? Is this safe? Won't this create a memory leak?String data = "some data";
TextWebSocketFrame frame = new TextWebSocketFrame(data)
channels.forEach(c -> {
c.write(frame.duplicate().retain());
}
}
frame.release()
Actually you want to call ByteBuf.retainedDuplicate() as you also need to increment the reference count.
On 12. Apr 2019, at 08:19, Frederic <fredb...@free.fr> wrote:
You can create one buffer and then use to send to all your sockets the very same buffer content but using different indexes (read here) using the ByteBuf.duplicate() method.Javadoc says:
public abstract ByteBuf duplicate()Returns a buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modifyreaderIndexorwriterIndexof this buffer.The reader and writer marks will not be duplicated. Also be aware that this method will NOT call
retain()and so the reference count will NOT be increased.
- Returns:
- A buffer whose readable content is equivalent to the buffer returned by
slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.
Le vendredi 12 avril 2019 06:31:57 UTC+2, matya...@gmail.com a écrit :Are there any optimizations available if I'd like to send the very same data to dozens (or hundreds) of Websocket channels?At a minimum I'd like to avoid creating (and copying) the data to new buffers. Ideally I would provide a single buffer and a list of channels.--
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 ne...@googlegroups.com.
--
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.
--You can create one buffer and then use to send to all your sockets the very same buffer content but using different indexes (read here) using the ByteBuf.duplicate() method.Javadoc says:
public abstract ByteBuf duplicate()Returns a buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modifyreaderIndexorwriterIndexof this buffer.The reader and writer marks will not be duplicated. Also be aware that this method will NOT call
retain()and so the reference count will NOT be increased.
- Returns:
- A buffer whose readable content is equivalent to the buffer returned by
slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.
Le vendredi 12 avril 2019 06:31:57 UTC+2, matya...@gmail.com a écrit :Are there any optimizations available if I'd like to send the very same data to dozens (or hundreds) of Websocket channels?At a minimum I'd like to avoid creating (and copying) the data to new buffers. Ideally I would provide a single buffer and a list of channels.
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 ne...@googlegroups.com.