Closed bastianeicher closed 10 years ago
Hi, I'll try to review the commit once I deal with my PC's disk failure...
Anyway, thanks for the input.
Finally I had some time to look at the patch. You definitely raised a good point here. I'm not sure about the whole implementation though. Couple things:
What do you think?
In case you are curious, this is where I am using your library: https://github.com/0install/0install-win/blob/master/src/Publish/EntryPoints/PosixBinary.cs Zero Install is a cross-platform "stateless" package manager and I am currently working on a GUI packaging tool for it. I use ELFSharp to automatically detect ELF binaries (along side Windows EXEs, Python scripts, etc.).
I think this change should resolve the problem, unless there are some missing usings that I overlooked. Could you look at it and close the pull request if it is satisfying?
On your project: interesting idea :) BTW, it can be very surprising how the library one provides will be used by people. When I first started this project, I could not find useful scenario for it apart from the one that I needed. And it turned out there are plenty.
Unfortunately there still seem to be leaking file handles. I will create some unit tests to reproduce my use case and try to narrow down what still needs to be disposed.
Have you managed to narrow down the case?
Your new Dispose method closes the stream opened in ELF's constructor. However, the NoteData constructor opens its own stream (using the readerSource callback) which is not disposed.
I'm sorry, I could finally some time to look at the issue. Please look at the proposed fix. Does it resolve all the problems?
Perfect, fixes all file handle leaks I encountered. Thank you. :)
After parsing an ELF file a few file handles are still open. This can be reproduced by trying to delete a file right after running ElfLoader.TryLoad(). This patch adds the missing using() Blocks.