How can i determine the minimum buffer size to avoid overflow. Theoretical reasons