1 year ago
#352159

dgo
Weird resource leak related to gulpfile or git or cmd prompt
I have a gulpfile
in a project directory. I use gulp frequently and this file is similar to my different gulpfile's
that I've used many times before.
I first became aware of this problem when I tried to merge a git commit and git threw an error that it couldn't unlink the gulpfile
. I assumed that the gulpfile
was in use by some other program, so I closed everything, including my command prompt, and terminated all processes that could theoretically be involved. Then I tried to merge in my git gui and got the same error.
I went into the directory using the command prompt and typed handle gulp
(handle
is a program by SysInternals that is designed to display information about what file handles are in use by what programs), and I see repeated instances of that gulpfile
that are in use by the cmd.exe
process I'm currently using and the handle.exe
command. One thing I eventually figured out is that every time I type handle gulp
, a new handle is created attached to the command prompt and attached to any other process that are started from the command prompt in that directory.
Here is an example screenshot:
I opened up mspaint to get the above screenshot, and then searched in process explorer for gulp and this is what I see:
I could chalk all this up to being something weird with file handles, but the fact that git is unable to unlink it indicates something weirder is going on. Keep in mind, at no point during any of this was the gulpfile
being executed.
This is what I've tried, more or less, to solve this:
- A variety of git commands to clean up the repo -
git fsck
, cleaned the dangling blobs. Also pruning and repacking and garbage collecting. handle filename
where filename is any other file in that directory. No leak. The output shows No matching handles every time with everything except for thegulpfile
.- Searched for alternate data streams, hidden files, broken links / reparse points, bad characters in filenames .. nothing.
- Searched the actual
gulpfile
for bad characters. Nothing. chkdsk /f
. The log said it cleaned up some indexes, but it didn't fix the problem.- Closing each individual handle. I tried doing this in process explorer as wells as by using
handle
command line switches. In both cases, I can close all the handles, but then they begin spawning again the next time I go into the directory with the command prompt. - Searched through gulp.js issues on github to try and find anything similar. I'd file an issue, but I tend to doubt gulp is the culprit - even though it sure seems to be involved somehow.
I think that might be everything. Any ideas?
UPDATE: Just checked. This process is repeatable with every single gulpfile
on my system - and as far as I can tell, no other files. This is too weird.
Other Update: I did eventually solve the git issue, but I'm still not sure what caused it, and the way I fixed it involved extra work and changing the master branch.
git
memory-leaks
gulp
handle
resource-leak
0 Answers
Your Answer