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

Should create a ISMBFileStore streaming file read method. #14

Closed
nddipiazza opened this issue Jan 17, 2019 · 4 comments
Closed

Should create a ISMBFileStore streaming file read method. #14

nddipiazza opened this issue Jan 17, 2019 · 4 comments

Comments

@nddipiazza
Copy link

By only supporting a read to byte[], causes out of memory situations on large files.
we should provide a ReadStream method that provides the stream to the data, or a WriteToOutputStream method.

@TalAloni
Copy link
Owner

You are missing multiple important points:

  1. The INTFileStore API is designed to match the Windows Native API.
  2. In 5 years of working with the library (and some very large files) I did not have a single issue with RAM usage.
  3. Using Streams does not magically reduce RAM usage.

I suggest you look for the real reason you are getting "out of memory".

@nddipiazza
Copy link
Author

nddipiazza commented Jan 17, 2019

for a simple use case, try to load a 10G file with a system with 6G available ram. you cannot load it all into a byte array, the program will crash with out of memory exception.

if you store an entire file into byte[] then you will use up the amount of ram equivalent to that file size. on a system with limited ram, you will run out of memory easily.

streaming on the other hand will not at any point store the entire file into the ram instead streams it to the consumer of the data so they can access it incrementally.

@TalAloni
Copy link
Owner

Of course you can't (and shouldn't) load an entire file into RAM. You also shouldn't load an entire file into a MemoryStream.
OutOfMemoryException is the result of inefficient programming, it can happen with both byte arrays and streams. the fact that you think that switching to streaming will somehow magically solve all your problems tell me that you are lacking experience.
When working with files, you should simply load (from the stream or other source of file data) the bytes that have been currently requested into the byte array, each SMB request is for about 64KB. so you shouldn't have any issues with excessive RAM usage.

In any case, I am not going to change the API. if you feel that the current API does not serve your special needs, feel free to fork the project and customize it to your needs.

@nddipiazza
Copy link
Author

ah that makes sense. i didn't look closely enough to see that you don't load the whole file at once. That was the piece I was missing.

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