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
filepath: filepath.Walk readDirName will cause large memory leak #36197
Comments
|
walkFn should before readDirNames |
Can you please include information about what version of Go you tested with ( When you say "large memory leak", what kind of numbers were you seeing? That will help with reproducing this and being able to make progress. Thanks. |
go version is 1.13.5 [root@el6 ~]# go env I have pull request #36198 Please review and merge it! When the directory has 8151134 files, it will cause 820MB meomory leak. the root cause is "names, err := readDirNames(path)" which read the large files of directory. Just swap the orders, User can SkipDir for this large directorys thank you for your attention to this matter @dmitshur |
There is already a PR for this: https://go-review.googlesource.com/c/go/+/211802. @wcc526 - I was not aware of this issue. Could you please link this issue in your PR ? In the PR message, just add a new line "Fixes #3697" |
Change https://golang.org/cl/211802 mentions this issue: |
does not seem these changes help much. walking a folder with 21k files still hogs about 82M RES size - after the walk. |
You should add filepath.SkipDir to skip this large files. these changes help to user to right control the SkipDir. Before change even if user skip large files, walk still |
Is this just waiting on a regress test? |
The API guarantees made by
The CL has been abandoned, with the recommendation that if you need a more performant API with a different tradeoff, you could copy and modify the |
https://github.com/golang/go/blob/master/src/path/filepath/path.go#L363
names, err := readDirNames(path)
the readDirNames will lead large memory if directory has large number of files
which conflict skipDir purpose.
The text was updated successfully, but these errors were encountered: