Skip to content
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

:unlink bookkeeping leaks open files #27

Open
taboege opened this issue Jun 24, 2018 · 1 comment
Open

:unlink bookkeeping leaks open files #27

taboege opened this issue Jun 24, 2018 · 1 comment

Comments

@taboege
Copy link

taboege commented Jun 24, 2018

I have a long-lived process which polls a web resource using the WWW module. WWW uses a fresh HTTP::UserAgent for every request, which in turn uses File::Temp for its cookie file. Since the process doesn't terminate soon, I get a lot of unused cookie files cluttering my /tmp and, which is worse, my process quickly runs out of file descriptors.

Now, there are three modules at play here. My current workaround is to ditch WWW and directly use a single HTTP::UserAgent, with a single tempfile. An argument could be made that HTTP::UserAgent should tidy up its cookie file if it's a temporary one, but the interface of File::Temp kind of promises to take care of that. I think File::Temp shouldn't uncontrollably hold onto every file it creates.

I'm not sure what should be done about this, though. Reading IO::Handle.close and the discussion about DESTROY in #18, which was quite some time ago, it seems that you can't reliably offer the :unlink adverb without using END, which forces you to keep track of all temporary files?

Somewhat related, my understanding is that the role File::Temp::AutoUnlink is completely useless at the moment, because %roster and %keptfd prevent the GC from collecting handles which are actually not used anymore. Correct? While DESTROY is not reliable for resource management, it would have provided a relief for my particular (long-running) case here.

@wukgdu
Copy link
Contributor

wukgdu commented Apr 21, 2021

I revert commit 21b3035 to let GC work (my fault) in https://github.com/wukgdu/p6-File-Temp,
and add words in readme and test about closing fh for Windows (opened files could not be unlinked on Windows).

Somewhat related, my understanding is that the role File::Temp::AutoUnlink is completely useless at the moment, because %roster and %keptfd prevent the GC from collecting handles which are actually not used anymore. Correct?

Things about DESTROY are not changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants