I'm writing a code that generates a large XML document and writes it directly into a client stream using StAX XmlStreamWriter. I'm afraid that if the network becomes extremely slow, the bytes written into the stream will actually stay in memory buffers for a relatively long time and consume a lot of memory on my server.
My question is: is there any way I can keep writing directly to the client stream, and avoid the potential memory problem I described above?