< prev index next >

src/share/vm/logging/logStream.cpp

Print this page
rev 13265 : imported patch 8181917-refactor-ul-logstream
rev 13266 : [mq]: 8181917-refactor-ul-logstream-delta-to-next

@@ -44,15 +44,21 @@
 // is larger than a reasonable max of 1 M. Caller must not assume
 // capacity without checking.
 void LogStream::LineBuffer::try_ensure_cap(size_t atleast) {
   assert(_cap >= sizeof(_smallbuf), "sanity");
   if (_cap < atleast) {
+    // Cap out at a reasonable max to prevent runaway leaks.
     const size_t reasonable_max = 1 * M;
-    size_t newcap = align_size_up(atleast + 64, 64);
     assert(_cap <= reasonable_max, "sanity");
-    // Cap out at a reasonable max to prevent runaway leaks.
+    if (_cap == reasonable_max) {
+      return;
+    }
+
+    size_t newcap = align_up(atleast + 64, 64);
     if (newcap > reasonable_max) {
+      log_info(logging)("Suspiciously long log line: \"%.100s%s",
+              _buf, (_pos >= 100 ? "..." : ""));
       newcap = reasonable_max;
     }
     
     char* const newbuf = (char*) os::malloc(newcap, mtLogging);
     if (newbuf == NULL) { // OOM. Leave object unchanged.
< prev index next >