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 leaks #78

Open
Coderitter-GmbH opened this issue Jan 4, 2021 · 4 comments
Open

Memory leaks #78

Coderitter-GmbH opened this issue Jan 4, 2021 · 4 comments

Comments

@Coderitter-GmbH
Copy link
Contributor

There are multiple memory leaks, which needs to be removed

@alrevuelta
Copy link
Owner

Yes, agree that we have some memory leaks. How did you find them? Unexpected crashes or were you using some tool like valgrind? Could you list the ones that you are aware of?

@Coderitter-GmbH
Copy link
Contributor Author

The hardware the library is running on has very limited ram (2 megabytes). It was running out of memory very quickly. For the detection of leaks i used the gcc address sanitizer. I have already some fixes but i wanted to discuss one more aspect. The memory used for an inference can be freed while the inference is running, to reduce the memory foot print. Only the results of prior node is needed to calculate the actual node.

@alrevuelta
Copy link
Owner

Could you provide the commands you used for the gcc address sanitizer? In the future some kind of memory leak detection should be included in the GitHub Action CI.

Regarding freeing memory from past nodes, I agree that there are some optimisations that can be made, but note that its not that straight forward. A model like mnist is a set of nodes connected in series to each other, so freeing the memory from the previous node output will work just fine, but there are more complex models that contain "branches" and "Only the results of prior node is needed to calculate the actual node." won't be true.

So we would need some kind of algorithm that scans the model an decides which outputs can be freed, and which ones will be needed later on in a different node. Having a flag with this choice (free unused outputs vs keep them) would be a really nice future, but imho it needs a bit of thinking. Feel free to open a new issue with this feature request :)

@Coderitter-GmbH
Copy link
Contributor Author

You can compile the software with the additional gcc flag -fsanitize=address. This will enable the address sanitizer, which detect out-of-bounds and use-after-free bugs and memory leaks.

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