You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Mehdi Salarkia (Jira)" <ji...@apache.org> on 2019/09/06 00:18:00 UTC
[jira] [Created] (CALCITE-3325) Thread Local Buffer Variable
(threadLocalBuffer) In ProtobufTranslationImpl Is Defined As Non Static
Causing Memory Leak
Mehdi Salarkia created CALCITE-3325:
---------------------------------------
Summary: Thread Local Buffer Variable (threadLocalBuffer) In ProtobufTranslationImpl Is Defined As Non Static Causing Memory Leak
Key: CALCITE-3325
URL: https://issues.apache.org/jira/browse/CALCITE-3325
Project: Calcite
Issue Type: Bug
Reporter: Mehdi Salarkia
As we weere load testing our system on Apache Phoenix via the thin client which uses Avatica we ran into Garbage collection problems. After some investigation we could see there are a lot of unreferenced object due to this variable:
{code:java}
private final ThreadLocal<UnsynchronizedBuffer> threadLocalBuffer =
new ThreadLocal<UnsynchronizedBuffer>() {
@Override protected UnsynchronizedBuffer initialValue() {
return new UnsynchronizedBuffer();
}
};
{code}
Which seems to be a reusable buffer for serializing/deserializing the data.
From my understating there is a copy of this variable created per each instance of ProtobufTranslationImpl. However the proper use of ThreadLocal it seems to be one instance per thread and the current implementation seems to be missing the `static` keyword when defining the thread local variable:
See [https://docs.oracle.com/javase/7/docs/api/java/lang/ThreadLocal.html]
{code:java}
ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID).
{code}
--
This message was sent by Atlassian Jira
(v8.3.2#803003)