Reputation: 20474
I would like to know which is the proper buffer size value to use in a .Net splitter/merger application that I'm developing, because to improve some FileStream I will set the same buffer size as Microsoft internally uses for copy operations in Windows.
I know this information exists and it is public because I seen this info in the past somewhere over Internet (maybe on MSDN) but I lost any references, if I remember good Microsoft uses 8 or 16 kb for buffer size, in any case is less than 1 MB for sure.
I'm looking for an official reference where Microsoft allegates the value they uses, or else some kind of technically demonstrable answer (maybe using Reflection?), please avoid answers like "I think they use X kb..." because is not demonstrable.
Upvotes: 0
Views: 509
Reputation: 13234
It is easy to check the default buffer sizes used by specific stream implementations, by checking the implementation in the reference source.
The default buffer size for e.g. a FileStream
is 4096 bytes.
The default buffer size for Stream.Copy
implementations is 80 Kb.
A good practice when choosing a buffer size yourself is:
Upvotes: 4