I ran a test loop opening up a small JSON file and closing it with defer f.Close(). At about 240, I started to get a "too many open files" error. When I changed the code to an explicit f.Close(), I no longer had the problem. Thoughts?I had first thought that my code was problematic in another section where I am opening up directories and was not doing a defer dir.Close() (or an explicit dir.Close()), but when I ran a loop to test this section, I never got the "too many open files" error. Is the error contingent on the size of the file/directory as opposed to just some number of open files/directories? Does Go automatically/eventually close directories? I'm confused...
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Yeah, right after posting, I thought a question like that would come up right after I made the post :-)The loop is actually connecting to a ZMQ server, so the defer code is actually running in a separate process from the loop. However, in the ZMQ code, I'm doing the following (note where the defer is commented out now), but that raises the question of whether or not f goes out of scope when the case goes out of scope. It should, right? Or is it then the function itself ends? If that's the case, then I have the same problem since the ZMQ server is running an endless loop...
The loop is actually connecting to a ZMQ server, so the defer code is actually running in a separate process from the loop. However, in the ZMQ code, I'm doing the following (note where the defer is commented out now), but that raises the question of whether or not f goes out of scope when the case goes out of scope. It should, right? Or is it then the function itself ends? If that's the case, then I have the same problem since the ZMQ server is running an endless loop...
Okay, thanks. Any insight on my second question?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.