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

Dropped messages of AsyncLogWriter cause memleak

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 17
    • 17
    • hotspot
    • b28
    • generic
    • 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

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

                Dates

                  Created:
                  Updated:
                  Resolved: