I found memory leak in stapler in class
the problem is caused by condition on row 213.
Unfortunately the fact that building is finished does not mean that we can write everything what remains.
Our Jenkins instance fell due to this bug. The scenario is quite easy (especially in case of smartfrog plugin where is used only full console, no skipping bytes).
1. Run job which creates a great log (several GB)
2. Open a log console of running build which log has had already several GB)
3. Open full console (without skipping bytes) and let it open in browser
4. Stop this build (so the log is finished and completed in aforementioned code is true)
5. You get out of memory (in case that your application has less memory then the size of log), because whole log which was not written is written in one shot to the memory because used output stream is in this case class CharSpool which write everything into memory.
I suggest not to use completed and write the rest of log in the same way as it is done with completed=false.
Please add your opinions into comments. Thanks