-
-
Notifications
You must be signed in to change notification settings - Fork 943
Description
In MRI, running the following code:
$$
# => 11989
10.times { f = File.open("/tmp/foo", "w") }Creates 10 open file descriptors; even though f is not referenced, the file descriptor remains. JRuby also behaves this way.
lsof -p 11989 | grep "/tmp/foo" | wc -l
#10
Now if I do:
GC.startlsof will no longer show any open file descriptors. wc -l is 1. JRuby does not do this. I can't seem to get JRuby to collect open file descriptors on a Garbage Collection. Any thoughts? I discovered this bug while sanity-checking my fix for this issue:
Initially, I "fixed" the issue by no longer caching the file descriptor. This should have resolved the issue, but the file descriptors stuck around, even after a garbage collection. GC.start seems to do nothing. One thing I did notice, is if I forced a garbage collection from VisualVM then all but one of the file descriptors would be collected (just like MRI).
So, I'm not sure.