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

Dropped messages of AsyncLogWriter cause memleak

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 17
    • 17
    • hotspot
    • b28
    • generic
    • generic

        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.

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

                Created:
                Updated:
                Resolved: