Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8269438 | 18 | Xin Liu | P3 | Resolved | Fixed | b04 |
JDK-8270625 | 17.0.1 | Xin Liu | P3 | Resolved | Fixed | b03 |
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.
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.
- backported by
-
JDK-8269438 Dropped messages of AsyncLogWriter cause memleak
- Resolved
-
JDK-8270625 Dropped messages of AsyncLogWriter cause memleak
- Resolved
- relates to
-
JDK-8229517 Support for optional asynchronous/buffered logging
- Resolved
(1 links to)