-
Notifications
You must be signed in to change notification settings - Fork 77
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
Support reading OLE stream as Stream #62
Comments
Is OpenMcdf.Extensions.CFStreamExtension.AsIOStream not good enough? |
@poizan42 I didn't know about that. There's a single OpenMcdf.dll in the current project and I've looked around it to no avail. Searching repo doesn't help either because there are so many CFStream in the result |
It's in OpenMcdf.Extensions: https://www.nuget.org/packages/OpenMcdf.Extensions |
I've checked the source code and it uses |
|
This should be now be addressed as part of #194 Small reads should be fast and efficient in the proof of concept. |
I need to save a stream (or parts of it) to a file, but in CFStream the only methods that can be used to get data are
Read(byte[] buffer, long position, int count)
andbyte[] GetData()
, thus I have to get abyte[]
buffer every time and write it to file. As the buffer is larger than 85000 bytes, it's put on the large object heap and the GC won't collect it right away even if it's not used anywhere else. As a result for big streams my app becomes a memory hog when saving big streams and I have to callGC.Collect()
manuallyI've written a custom class to wrap
CFStream
that extendsSystem.IO.Stream
and callsCFStream.Read()
inside itsRead
overload, but the result is that performance is almost 10 times slower. I debugged and found out that there are a lot of small reads from the stream and a new StreamView is created even when reading just a single byte. After readingGC.Collect()
is called, thus there are a lot of GC wake ups in 1 secondI ended up working around the issue by wrapping another layer of System.IO.BufferedStream. But it looks like the issue can be solved much easier and more efficient by exporting
StreamView
which is currently aninternal
class. We just need to make itpublic
, or probably some other small changes to make it workThe text was updated successfully, but these errors were encountered: