On Thursday, 14 January 2021 at 16:47:45 UTC, drug wrote:
On 1/14/21 7:06 PM, dog2002 wrote:
On Thursday, 14 January 2021 at 16:01:43 UTC, drug wrote:
On 1/14/21 6:55 PM, drug wrote:
But this method consumes a huge amount of memory (up to
4 GB and more). Is there a more appropriate way to walk
directories recursively that does not consume a lot of
memory?
DirEntry is a struct. First of all I would try this:
```D
foreach(ref entry; dirEntries(path, SpanMode.shallow, false))
```
Does your directory just contain large amount of files?
Yes. I forgot to add it in the original post.
How much files do you have? DirEntry size is 168 bytes only and
dirEntry is lazy range so I'm curious what is the reason of
huge memory consumption. Do you use Windows 32 bits between?
About 1000 large files.
I want to replace several first bytes in all the files, so I just
copy the remaining bytes into a new file. Might this be the
reason for high memory consumption? If so, is there a way not to
copy the entire file, just delete first bytes and write the
replaced bytes into the beginning of the file?
I use Windows x64.