Nio (selector (Bytebuffer size allocation))

Nio (selector (Bytebuffer size allocation))

 

*Bytebuffer cannot be used by multiple channels together

*If we allocate a Bytebuffer of 1Mb, then 1Tb of memory is required for millions of connections. The server is not enough

Solutions:

  1. If the small Bytebuffer is not enough, give a large Bytebuffer. It involves data copying, and the performance is almost
  2. Bytebuffer arrays, multiple arrays form a buffer, so access is discontinuous (a single array is continuous in data memory, deletion can only be overwritten, not directly deleted)

Guess you like

Origin blog.csdn.net/logtcm4/article/details/127821078