Since you're talking about optimisation, does that mean you have already implemented the desired functionality and are now trying to improve its performance, based on code profiling and on the discovery that knowledge of the buffer size would be helpful in opening the bottleneck?