Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269064

Dropped messages of AsyncLogWriter cause memleak

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b28
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        The obvious problem is the following code. msg contains a new string from os::strdup(msg). when we decide to drop the message, we need to call os::free for the string, or memory leaks.

        void AsyncLogWriter::enqueue_locked(const AsyncLogMessage& msg) {
          if (_buffer.size() >= _buffer_max_size) {
            bool p_created;
            uint32_t* counter = _stats.add_if_absent(msg.output(), 0, &p_created);
            *counter = *counter + 1;

            // drop the enqueueing message.
            return;
          }


        There's another not so obvious memleak issue. In AsyncLogMapIterator, we clear counters to zero. If the LogOutput has deleted by LogConfiguration::delete_output(), we should delete the corresponding entry of AsyncLogWriter::_stats. It's because user can delete/add logOutput instances via jcmd. hotspot gradually leaks memory if we don't drop deleted LogOutputs.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                xliu Xin Liu
                Reporter:
                xliu Xin Liu
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: