-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix networking memory leaks and file transfer issues #1578
base: nightly
Are you sure you want to change the base?
Conversation
…ion created another instance when calling MemoryManager#instance()
… cache's max size per buffer. This should reduce off heap memory usage significantly, when enabled
…ent. Should help prevent future leaks
As far as I can tell the buffers you are force closing now are getting garbage collected anyway. The provided stacktrace in the corresponding issue tells the same. |
The buffers get GC'd, that is correct. However, netty uses native/off heap memory, which is not cleaned up properly. Every buffer allocated with netty must be freed explicitly, see netty/netty#11347:
Though those buffers are not currently freed, this is why I added the close calls. |
This should be handled as we wrap the drop of the buffer in a CleanerDrop which then delegates to our DirectBufferFreeDrop which explicitly frees the off-heap memory that is used by the buffer |
I mean... Turn on leak detection
and try if the current code works. I am using this PR currently, before I used this leaks everywhere, after I started using this I haven't seen a single leak from netty. |
Yes... because netty just tells you that the drop was garbage collected before close was called (handled by CleanerDrop as well)... Doesn't mean that the native memory is still in use/reserved after garbage collection |
Are you trying to tell me that explicitly clearing the buffer everywhere in the code except those 3 places is intended? Line 114 in 31b4a99
Line 54 in 31b4a99
Line 98 in 31b4a99
+implicit releases Line 335 in 31b4a99
... If we argue that the garbage collector cleans up anyway, why do we even bother reference counting? |
Idk what you're on about, but I'm just telling you that the buffers are released even if they leak (in response to your |
Just because netty is smart enough to detect when leaks happen, doesn't mean the leaks are supposed to happen in the first place is what I am on about. |
Motivation
Networking has quite a few issues. There are multiple memory leaks because listeners or query handlers do not clear the packet content buffer.
Also there is a shocking lack of error logging in networking code, making theoretically obvious issues difficult to debug.
Modification
ByteBufferMemoryManager
instance. The memory manager doesn't have a state, so it should be fine to have 2 instances, but whyyy?Result
->Repeated file transfer works without OOME with option enabled (File transfer sometimes doesn't work #1572)
Other context
Fixes #1577
Fixes #1572