rsync icon indicating copy to clipboard operation
rsync copied to clipboard

Memory leak or similar when deleting lots of files

Open rossburton opened this issue 2 years ago • 3 comments

I regularly need to delete pretty large directory trees (a few gigabytes) and the internet suggested rsync from an empty directory being faster than rm due to it's more optimised file access patterns.

$ mkdir empty
$ rsync -a --delete empty/ dir/to/delete
[generator] exceeded --max-alloc=1073741824 setting (file=ifuncs.h, line=30)
rsync error: error allocating core memory buffers (code 22) at util2.c(80) [generator=3.2.7]

rossburton avatar Dec 04 '23 10:12 rossburton

Can you try with

--max-alloc=0

Regards, Simon

realsimix avatar Dec 05 '23 07:12 realsimix

I tried with the local tree I wanted to delete and it didn't crash, but watching ps the peak memory usage was just 1117120 so that wasn't big enough.

Isn't using --max-alloc a workaround rather than a fix?

rossburton avatar Dec 05 '23 14:12 rossburton

From how I understand it rsync tries to not use too much memory. Certain operations with large filesystems may require more memory than rsync uses by default and you can therefore specify the limit with the --max-alloc option. If you want rsync to consume as much memory as you have you can set max-alloc to 0.

So, it's not a workaround but just disables rsyncs' habit of being too memory friendly.

realsimix avatar Dec 05 '23 14:12 realsimix