websocket icon indicating copy to clipboard operation
websocket copied to clipboard

add memory pool to alternative option

Open someview opened this issue 6 months ago • 2 comments

Is there an existing feature request for this?

  • [x] I have searched the existing feature requests

Is your feature request related to a problem? Please describe.

We have the problem receiving a lot of small websocket packet. The lib alloc a lot of small object:

// case 1
reader,_,_ :=conn.NextReader()
// case 2
 buf,_, _      := conn.ReadeMessage()

Describe the solution that you would like.

In great small packet case, a sync pool is needed. This cound be alternative option for the lib

Describe alternatives you have considered.

No response

Anything else?

No response

someview avatar Jul 15 '25 00:07 someview

ReadMessage is a helper function that calls the lower-level NextReader and io.Reader methods. Call the low-level methods directly to control memory allocation.

ghost avatar Jul 15 '25 06:07 ghost

ReadMessage is a helper function that calls the lower-level NextReader and io.Reader methods. Call the low-level methods directly to control memory allocation.`

the memory ReadMessage method that allocs more than nextReader method. We want the way to reduce memory alloction for a lot of small packet

someview avatar Jul 15 '25 08:07 someview