This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 269576 - The PrintStreamLogger flush thread may starve, memory not freed
Summary: The PrintStreamLogger flush thread may starve, memory not freed
Status: RESOLVED FIXED
Alias: None
Product: ide
Classification: Unclassified
Component: Logger (show other bugs)
Version: 7.4
Hardware: PC Linux
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-16 19:20 UTC by Svata Dedic
Modified: 2017-06-22 10:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (12.26 KB, patch)
2017-01-17 17:09 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Svata Dedic 2017-01-16 19:20:19 UTC
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.
Comment 1 Svata Dedic 2017-01-17 17:09:20 UTC
Created attachment 163414 [details]
Proposed patch

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.
Comment 2 Quality Engineering 2017-03-01 02:52:15 UTC
Integrated into 'main-silver', will be available in build *201703010002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/583524e1647d
User: Svata Dedic <sdedic@netbeans.org>
Log: #269576: printstream flushed in parallel if large data is written to it