There is a data type mismatch between data processing and data transfer in web applications.
We need to generate the page and process it by chars, but finally we need to send it out by sockets which can only handle bytes. So we need to encode chars to bytes all the time.
String class provides a getBytes() method which can to the encode automaticly, but it is not very effective, because it does a few unnecessay copy protection. To avoid these copying i create a CharsetEncoderUtil which utilize NIO's encoding mechanism directly. This can save a lot of temp encoding buffers.
MessageBoard benchmark result shows that this fix can save about 3% young gen collections