In the case the process continuously floods System.err, but does not call flush(), the background writer will be always postponed to a later time and will not actually run until after the intensive logging activity ceases.
Memory allocated to the internal StringBuilder will be never reclaimed although it won't be used for a long time.
As a result, a computation that logs huge data piece by piece will first (unnecessarily) allocate a lot of memory, which is not freed until the IDE exit.
Some other defects may be related to this: issue #258932, #250915, #246940, #245437, #242021, #237367
Occurs in NetBeans 7.4 and above, I didn't check earlier versions.
Created attachment 163414 [details]
pls. review proposed patch + test. The intention is to
a/ start flush thread if the buffer size exceeeds some threshold, so the Logger receives output even while the data is still produced at rapid rate.
b/ after the activity that requires large buffer ceases, the buffer is eventually recycled to reclaim (presumably) large memory.
Integrated into 'main-silver', will be available in build *201703010002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Svata Dedic <firstname.lastname@example.org>
Log: #269576: printstream flushed in parallel if large data is written to it