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

is there a way to handle out-of-memory errors more cleanly? #182

Open
ctb opened this issue Jan 17, 2025 · 3 comments
Open

is there a way to handle out-of-memory errors more cleanly? #182

ctb opened this issue Jan 17, 2025 · 3 comments

Comments

@ctb
Copy link
Contributor

ctb commented Jan 17, 2025

it may be possible to catch and ignore or flag out of memory errors within Rust; this would be a nice UI improvement since right now it's not clear that's what's going on when it happens.

@bluegenes
Copy link
Collaborator

Do you mean track the total memory we have an try to avoid OOM?

Looks like we could use sysinfo to check available memory, but I'm not sure how to do it mid-download and stop a download if no memory is available.

Maybe we could prevent downloads from starting if available memory exceeds the maximum size of a download thus far? Or we could maybe delay processing a file into signatures if there isn't sufficient memory available?

@bluegenes
Copy link
Collaborator

also ref #47 - is there a way to chunk downloads and still check the md5sum?

@ctb
Copy link
Contributor Author

ctb commented Jan 18, 2025

Re OOM errors, I was wondering if we could actually catch the error itself - it is not necessarily straightforward generally, but I was curious. Some googling found some links - this makes for interesting reading:

https://doc.rust-lang.org/stable/nomicon/vec/vec-alloc.html

as does this:

https://users.rust-lang.org/t/handling-memory-exhaustion-state-of-the-art/87375

and maybe this :)

https://stackoverflow.com/questions/44923306/why-doesnt-boxnew-return-an-option-or-result

and this

https://www.reddit.com/r/rust/comments/qinvlr/does_rust_really_abort_on_allocation_failure/

but I don't see a super clear answer except maybe in the first link.

The best plan would be to go look at the library you're using for downloads & unpacking and see if there are any handles to track failures to allocate.

Alternatively, we could think about downloading the files to a temporary disk space and processing them from there.

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