websocket/examples
LiuYang 80393295c1
Correct way to save memory using write buffer pool and freeing net.http default buffers (#761)
**Summary of Changes**

1. Add an example that uses the write buffer pool

The loop process of the websocket connection is inner the http handler
at existing examples, This usage will cause the 8k buffer(4k read buffer
+ 4k write buffer) allocated by net.http can't be GC(Observed by heap
profiling, see picture below) . The purpose of saving memory is not
achieved even if the WriteBufferPool is used.

In example bufferpool, server process websocket connection in a new
goroutine, and the goroutine created by the net.http will exit, then the
8k buffer will be GC.


![heap](https://user-images.githubusercontent.com/12793501/148676918-872d1a6d-ce10-4146-ba01-7de114db09f5.png)

Co-authored-by: hakunaliu <hakunaliu@tencent.com>
Co-authored-by: Corey Daley <cdaley@redhat.com>
2023-08-17 11:25:09 -04:00
..
autobahn Update autobahn example 2022-01-02 11:21:21 -08:00
bufferpool Correct way to save memory using write buffer pool and freeing net.http default buffers (#761) 2023-08-17 11:25:09 -04:00
chat Modify http Method String Literal to Variable (#728) 2021-12-19 11:21:45 -05:00
command Modify http Method String Literal to Variable (#728) 2021-12-19 11:21:45 -05:00
echo Update source to match output from gofmt 1.17 2021-12-17 22:48:51 -05:00
filewatch Modify http Method String Literal to Variable (#728) 2021-12-19 11:21:45 -05:00