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

Memory leak in serial mode #34

Open
dreammaker opened this issue Oct 12, 2015 · 1 comment
Open

Memory leak in serial mode #34

dreammaker opened this issue Oct 12, 2015 · 1 comment

Comments

@dreammaker
Copy link
Contributor

The following loop that simply moves back and forth will slowly consume more and more memory, presumably until it crashes.

g = G(direct_write_mode='serial')
while True:
    g.move(10, 0)
    g.move(-10, 0)

The problem is that the Printer class is storing every line ever sent in _buffer and doesn't clear it out until disconnecting.

@DerAndere1
Copy link
Contributor

DerAndere1 commented Oct 21, 2019

Conservatively assuming 20 characters per G-code command, 1,000,000 G-code commands would require roughly 72 + (37+20*7+8 )*1000000 bytes = 185000000 bytes = 185 MB for _buffer and another 185MB for the responses list (for calculation see https://code.tutsplus.com/tutorials/understand-how-much-memory-your-python-objects-use--cms-25609 ). If it is possible to replace those lists with ring buffers, that would be a nice change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants