--- old/src/share/vm/logging/logStream.cpp 2017-07-19 17:21:41.237259100 +0200 +++ new/src/share/vm/logging/logStream.cpp 2017-07-19 17:21:40.282714500 +0200 @@ -53,7 +53,8 @@ return; } - size_t newcap = align_up(atleast + 64, 64); + const size_t additional_expansion = 256; + size_t newcap = align_up(atleast + additional_expansion, additional_expansion); if (newcap > reasonable_max) { log_info(logging)("Suspiciously long log line: \"%.100s%s", _buf, (_pos >= 100 ? "..." : "")); @@ -79,11 +80,12 @@ void LogStream::LineBuffer::append(const char* s, size_t len) { assert(_buf[_pos] == '\0', "sanity"); assert(_pos < _cap, "sanity"); - try_ensure_cap(_pos + len + 1); + const size_t minimum_capacity_needed = _pos + len + 1; + try_ensure_cap(minimum_capacity_needed); // try_ensure_cap may not have enlarged the capacity to the full requested // extend or may have not worked at all. In that case, just gracefully work // with what we have already; just truncate if necessary. - if (_pos + len + 1 > _cap) { + if (_cap < minimum_capacity_needed) { len = _cap - _pos - 1; if (len == 0) { return; @@ -102,7 +104,7 @@ void LogStream::write(const char* s, size_t len) { if (len > 0 && s[len - 1] == '\n') { _current_line.append(s, len - 1); // omit the newline. - _log_handle.print("%s", _current_line.ptr()); + _log_handle.print("%s", _current_line.buffer()); _current_line.reset(); } else { _current_line.append(s, len);