franz1981 commented on issue #2832: ARTEMIS-2482 Large messages could leak 
native ByteBuffers
URL: https://github.com/apache/activemq-artemis/pull/2832#issuecomment-530319911
 
 
   @wy96f I've taken a second look to the way Netty handle thread local pools 
and I can confirm that `-Dio.netty.allocator.useCacheForAllThreads=false` 
should save non-netty threads from creating such thread local regions for 
tiny/small/medium sized buffers.
   While related to 
   > but they just contain wrappers to direct memory that cannot be released 
(is part of the pool and they have no cleaner). The impact should be way less 
then IOUtil that pool native ByteBuffers holding exclusively native memory that 
won't be reused anymore...
   
   I have to add more detail and I was wrong: the tiny/small/medium thread 
local caches are actually leaking memory regions (with default 
`io.netty.allocator.useCacheForAllThread`) that need the holding thread to die 
in order to make the available to other threads, but their size is quite small 
by default and the size I've chosen as `LARGE_MESSAGE_CHUNK_SIZE` (ie 100 * 
1024) is `medium` but doesn't fall in any of those caches, so no real leak will 
happen until we allocate something smaller (could happen but is rare).
   IMO we should consider (for a separate issue) 2 separate improvements:
   - allow threads to stay alive forever, but just idle (and maybe using the FJ 
thread pool executor instead of the AMQ thread pool executor in that case): in 
that case we can consider such caches to be ok to be used by *all* threads 
(including non-netty ones), because the leak is just to cope with future load
   - for the AMQ thread pool executor as it is, make the presence of such 
caches configurable and off by default
   
   wdyt?
   Thanks for the comment, good catch!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to