You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Blake Bender (Jira)" <ji...@apache.org> on 2021/04/26 16:41:00 UTC
[jira] [Updated] (GEODE-9193) PING message "leaked" at shutdown due
to bad singleton implementation
[ https://issues.apache.org/jira/browse/GEODE-9193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Blake Bender updated GEODE-9193:
--------------------------------
Description:
There is a micro-optimization in the native client to prevent creating and tearing down PING messages multiple times, since this message always has the same format. Unfortunately, the implementation uses a pointer, rather than a reference, so exactly one instance of TcrMessagePing is allocated on the heap, and the object is never deleted, making it appear as a leak in any leak-tracking tool.
{quote}TcrMessagePing* TcrMessage::getPingMessage(CacheImpl* cacheImpl) {
static auto pingMsg = new TcrMessagePing(new DataOutput(cacheImpl->createDataOutput()), true);
return pingMsg;
}
{quote}
Changing this from a pointer to a const reference will allow the object to be destructed properly at shutdown.
was:
There is a micro-optimization in the native client to prevent creating and tearing down PING messages multiple times, since this message always has the same format. Unfortunately, the implementation uses a pointer, rather than a reference, so exactly one instance of TcrMessagePing is allocated on the heap, and the object is never deleted, making it appear as a leak in any leak-tracking tool.
```
TcrMessagePing* TcrMessage::getPingMessage(CacheImpl* cacheImpl) {
static auto pingMsg =
new TcrMessagePing(new DataOutput(cacheImpl->createDataOutput()), true);
return pingMsg;
}
```
Changing this from a pointer to a const reference will allow the object to be destructed properly at shutdown.
> PING message "leaked" at shutdown due to bad singleton implementation
> ---------------------------------------------------------------------
>
> Key: GEODE-9193
> URL: https://issues.apache.org/jira/browse/GEODE-9193
> Project: Geode
> Issue Type: Bug
> Components: native client
> Reporter: Blake Bender
> Assignee: Blake Bender
> Priority: Major
>
> There is a micro-optimization in the native client to prevent creating and tearing down PING messages multiple times, since this message always has the same format. Unfortunately, the implementation uses a pointer, rather than a reference, so exactly one instance of TcrMessagePing is allocated on the heap, and the object is never deleted, making it appear as a leak in any leak-tracking tool.
> {quote}TcrMessagePing* TcrMessage::getPingMessage(CacheImpl* cacheImpl) {
> static auto pingMsg = new TcrMessagePing(new DataOutput(cacheImpl->createDataOutput()), true);
> return pingMsg;
> }
> {quote}
>
> Changing this from a pointer to a const reference will allow the object to be destructed properly at shutdown.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)