Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection.send_binary() out of memory #340

Open
michl2310 opened this issue Feb 10, 2022 · 2 comments · May be fixed by #355
Open

connection.send_binary() out of memory #340

michl2310 opened this issue Feb 10, 2022 · 2 comments · May be fixed by #355
Labels
bug Something isn't working

Comments

@michl2310
Copy link

Hello,

I encountered a problem when sending binary data through websockets using connection.send_binary().

Example:
datasize is >1MB
connection is slow (using vpn)

while(true) {
connection.send_binary(data);
sleep(100);
}

My guess is that the sending data1 has not completed yet and the new send triggers.
Data2 is being added to a sendbuffer which contains the old data1 and now new data2.
Data1 has been send in the meantime. Send triggers again. Even newer data3 is being added to the buffer.
Now the buffer contains data1, data2 and data3.
In my test the memory has been released only after all sends were completed.
If I used this loop, the sending queue never ends leading to a increasing memory consumption causing out of memory.

Has anyone encountered a similar problem?
What can I do in order to avoid out of memory errors when having slow connections?

@The-EDev The-EDev added the bug Something isn't working label Feb 10, 2022
@The-EDev
Copy link
Member

I'm not sure if this can be solved in the framework itself (and how it go about it), but since you're using websockets, you can wait for the client to acknowledge receiving the data before sending any new data its way.

@The-EDev The-EDev changed the title connection.send_binary() out of memory connection.send_binary() out of memory Feb 10, 2022
@dranikpg
Copy link
Member

The connection should provide backpressure and block in this case, until the buffers become less than some acceptable threshold. This should however be somewhat tricky with ASIO

@michl2310 michl2310 linked a pull request Feb 24, 2022 that will close this issue
@The-EDev The-EDev linked a pull request Apr 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants