Skip to content

It eats tremendous amout of memory on high load #134

Closed
@softaria-roman

Description

@softaria-roman

Hello
I tried to use it for real time MMO game. And got a problem with garbage collector working constantly.
With 1000 clients each sending and receiving 100 messages per second library generates ~10 Gb of memory in 2 minutes.
In contrast, google's x/net/websocket generates about 10 times less work for gc.
Here is 2 first line from profiler gathered during 2 min of work:

(pprof) top10
12.02GB of 12.47GB total (96.38%)
Dropped 63 nodes (cum <= 0.06GB)
Showing top 10 nodes out of 35 (cum >= 0.10GB)
flat flat% sum% cum cum%
6.73GB 53.94% 53.94% 6.73GB 53.94% bytes.makeSlice
2.30GB 18.45% 72.38% 9.02GB 72.38% io/ioutil.readAll

Here is a place where the memory usage get generated
g1
g2

It could be easily fixed when you would allow passing pre-allocated buffers as arguments to readMessage instead of allocating it per each frame.

I am ready to provide any further information when you are interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions