Byron / dua-cli

View disk space usage and delete unwanted data, fast.
https://lib.rs/crates/dua-cli
MIT License
4k stars 109 forks source link

Can cause memory leak for xdg-desktop-portal #56

Open tim77 opened 4 years ago

tim77 commented 4 years ago

Memory leak happens when running dua on root / partition, see related bug.

How to reproduce:

Just install some flatpak apps system-wide and run them before. Then run dua on /.

Byron commented 4 years ago

By the looks of it, the proc filesystem contains a cycle, trapping unsuspecting programs in it. If that's truly the case, I wonder if that's a bug in Flatpack more than a bug in any tool that rightfully (?) expects filesystems trees to be acyclic.

Regarding memory usage: In order to handle hard-links, a mapping is maintained from inodes with more than one reference. In interactive mode, all traversed file paths will be kept in memory for later traversal. That's not a leak, but the cost of providing certain capabilities.

If the proc filesystem somehow does produce cycles, this issue would probably become something like handle cyclic filesystems gracefully , as right now it would probably go into an infinite loop.

In order to make this issue actionable, more information is required, maybe you can help answering these questions of mine:

Thank you

tim77 commented 4 years ago
tim77 commented 4 years ago

Seems like not. Problem comes from here dua /run/user/

Byron commented 4 years ago

Thanks for looking into this and for narrowing down the cause of the issue. As I am on MacOS, I can't exactly reproduce this issue easily, and would be relying on a PR fixing it or on way more information on what you think is causing this within /run/user. Thanks again

tim77 commented 4 years ago

If be more precisely: dua /run/user/1000/doc/ causing this. There is place for flatpak portals but what exactly causing this i am still trying to investigate... Maybe we can safely exclude this path for now in dua?

Byron commented 4 years ago

Thanks for digging in! I believe that hardcoding exceptions without understanding the root cause is not really going to help in the long-term, and thus would be happy to wait until you figured out what is causing this.

By the way: if you run dua i /run/user you can interactively dig into the directory as it is parsing it - maybe that helps to see what's going on.