mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
[GH-ISSUE #369] Dust memory leak #168
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MathMan05 on GitHub (Feb 16, 2024).
Original GitHub issue: https://github.com/bootandy/dust/issues/369
I attempted to use the system version of dust after someone recommended it to me in a discord server I'm in and it had a bit of a memory leak when it tried to run, I'm on version 0.9.0 Arch Linux, btrfs filesystem. I did

sudo dust /just to see what that might look like it tried to scan my file system and ended up taking 30Gibs of RAM before I killed it after taking a screenshot of that. I am including a screenshot of the output of dust.I only have a 256Gib SSD in my laptop so this should not be happening. Feel free to ask aditional questions as needed.
@bootandy commented on GitHub (Feb 19, 2024):
It will scan network drives and USB drives if you have anything mounted. This will result in more than your hard disk being scanned.
What does 'du' say when run from root?:
sudo du -h -d 1Also consider, what does dust print if you let it finish ? What about if you run it on each of the folders that are one up from the root ?
@MathMan05 commented on GitHub (Feb 20, 2024):
I can't let dust finish, I don't have enough ram lol. du is also stalling but using way less ram, and due to that it can finish.
I just figured the problem out though, they're trying to index ./snapshots and neither tool is aware of btrfs, counting things multiple times, as you can see with
/.snapshots. While this is not as much of a bug as I thought it was, dust is still having a rather large memory leak, causing it to fill my ram.@bootandy commented on GitHub (Feb 21, 2024):
So does dust crash? What's the error ? Is it killed due to an OOM Error? Do you see this:
fatal runtime error: stack overflow?Remember dust is trying to summarize every file on your harddisk. This will use a lot of RAM and it may fallover if the OS can't allocate enough virtual memory.
In the shortterm you could try ignoring the snapshots directory:
dust -X snapshots
@bootandy commented on GitHub (Feb 22, 2024):
Does running it single threaded make any difference?
export RAYON_NUM_THREADS=1; dust /
@MathMan05 commented on GitHub (Feb 22, 2024):
Dust used 30Gib of ram, I had to force close it. Sorry for the late reply, was busy during the day. du used at most 100Mibs of RAM, while dust used 30Gib before I had to force close it as it was just about to fill up all my RAM. Though dust itself throws no error. And dust is still seeing multiple times the size on my SSD in files, due to the /.snapshots dir, as that dir is full of simlink like objects, which instead of being true simlinks, make / COW, and they are an instant in time. I don't know if it's intentional to crawl the COW dirs and count those files multiple times. The command you provided did not fix anything, though the amount of snapshots had decreased, so it only took up arround 15-17Gibs of RAM, which still seems like a memory leak to me.
@YanWQ-monad commented on GitHub (Feb 22, 2024):
Could you run
find /.snapshots | wc -cto check the total length of all the file path? Too many long paths could take up a large amount of memory, since dust will cache all the paths in the memory.In my system, a directory with 600 MiB total length of file path, will cause dust uses up to 1.8 GiB memory.
@bootandy commented on GitHub (Feb 24, 2024):
I've heard of some problems with COW files. They are sadly considered different files. It's annoying but as far as i understand the tooling within rust: https://doc.rust-lang.org/std/fs/struct.Metadata.html doesn't let me detect it.
If you want to use dust I think you'll have to ignore snapshots dir:
Also try @YanWQ-monad's idea, (thanks Yan).
Dust is tracking all your filepaths, By some definitions this is considered a "memory leak" but personally its one I find useful. It might be that using du is better suited to your usecase Alternatively run dust on a subfolder instead of the root.