Memory leak in Camel netty TCP client when consuming lines with Windows line breaks (CR LF)

Memory leak in Camel netty TCP client when consuming lines with Windows line breaks (CR LF)

By : Randy Lam
Date : October 18 2020, 06:10 AM
around this issue Heap dump analysis showed that the memory is getting allocated by one instance of io.netty.util.concurrent.DefaultEventExecutor which is using a LinkedBlockingQueue with unlimited size internally. This queue grows indefinitely under load causing the issue.
The DefaultEventExecutor is created by Camel because of the parameter usingExecutorService which is true by default (maybe not a good choice). Setting usingExecutorService=false makes Netty use its event loop instead of the executor which works much better.
code :
public abstract class MyRouteBuilderTestBase extends CamelTestSupport {
    private final int nettyPort = AvailablePortFinder.getNextAvailable();

    private ServerSocket serverSocket;
    private Socket clientSocket;
    private PrintWriter out;

    protected JndiRegistry createRegistry() throws Exception {
        JndiRegistry registry = super.createRegistry();

        List<ChannelHandler> decoders = new ArrayList<>();
        DefaultChannelHandlerFactory decoderTextLine = new DefaultChannelHandlerFactory() {
            public ChannelHandler newChannelHandler() {
                return new io.netty.handler.codec.DelimiterBasedFrameDecoder(1024, true, Delimiters.lineDelimiter());
                // Works too:
                // return new LineBasedFrameDecoder(1024, true, true);
        ShareableChannelHandlerFactory decoderStr = new ShareableChannelHandlerFactory(new StringDecoder(CharsetUtil.US_ASCII));
        registry.bind("decoders", decoders);

        List<ChannelHandler> encoders = new ArrayList<>();
        ShareableChannelHandlerFactory encoderStr = new ShareableChannelHandlerFactory(new StringEncoder(CharsetUtil.US_ASCII));
        registry.bind("encoders", encoders);

        return registry;

    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                from("netty4:tcp://localhost:" + nettyPort + "?clientMode=true&textline=true&sync=false&usingExecutorService=false&encoders=#encoders&decoders=#decoders")

    protected void startServerStub(String testdata) throws Exception {
        serverSocket = new ServerSocket(nettyPort);
        clientSocket = serverSocket.accept();
        out = new PrintWriter(clientSocket.getOutputStream(), true);
        for (;;) {

    public void after() throws Exception {
        if (out != null) out.close();
        if (clientSocket != null) clientSocket.close();
        if (serverSocket != null) serverSocket.close();

Share : facebook icon twitter icon
UITextView memory leak when line breaks are present

UITextView memory leak when line breaks are present

Date : March 29 2020, 07:55 AM
I hope this helps you . Based on the fact that you only get the error from your custom UITextView subclass, the problem is obviously from your implementation.
The most likely cause is your implementation of the layoutSubview function. The only types of things you should do in that overridden function is to adjust frames as needed.
Camel Client for netty tcp port using

Camel Client for netty tcp port using

By : jimmythedragon
Date : March 29 2020, 07:55 AM
this will help I'm not totally clear on what you're asking. But if you're using Camel 2.15 or greater the option of clientMode, found in small print here, may be of use to you.
It'll prevent the pesky bind exception.
code :
Camel and Netty: client - intermediary app - server

Camel and Netty: client - intermediary app - server

By : Vivek Raskar
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Running the code you shared gives the following error in the Router class io.netty.channel.ChannelPipelineException: io.netty.handler.codec.bytes.ByteArrayDecoder is not a @Sharable handler, so can't be added or removed multiple times.
As the exception says, the ByteArrayDecoder as well as ByteArrayEncoder are not sharable handlers and thus the reason for the error. From the javadoc of Sharable, it clearly states that
code :
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {


public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {


public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {


public ChannelHandler newChannelHandler() {
    return new ByteArrayDecoder();
SimpleRegistry registry = new SimpleRegistry();
registry.put("ByteArrayEncoder", new CustomByteArrayEncoder());
registry.put("ByteArrayDecoder", new CustomByteArrayDecoder());
Entity Framework consuming a lot of memory (possible memory leak?)

Entity Framework consuming a lot of memory (possible memory leak?)

By : gopal
Date : March 29 2020, 07:55 AM
this will help We had a similar issue when recursively querying a lot of records (millions) without disposing the DbContext. With the state-less nature of WCF services, and because you are disposing of the 'DbContext', this likely is not your problem (unless each user is simultaneously pulling a lot of data into context in one method call).
Ensure that you have each block of database logic wrapped in a using statement. This should allow the garbage collector to remove everything in context from memory.
Netty 4.0.19.Final Memory Leak with io.netty.channel.ChannelOutboundBuffer$Entry

Netty 4.0.19.Final Memory Leak with io.netty.channel.ChannelOutboundBuffer$Entry

By : george uwe
Date : March 29 2020, 07:55 AM
help you fix your problem It's probably due to a wrong usage of reference counted object (a new principle introduced in Netty 4). Your channel doesn't correctly release an object.
You can use -Dio.netty.leakDetectionLevel=paranoid to activate an auto memory leak detection in Netty.
Related Posts Related Posts :
  • How do I set random numbers that fall in a range in kdb+?
  • Computer graphics: programatically create duotone (or separations)
  • Adding more attributes to LINQ to SQL entity
  • How to write an application to stimulate clicking events on Mobile
  • Drupal Background Image as Block or Node
  • Usage Tracking for Windows desktop applications
  • NLP: any easy and good methods to find semantic similarity between words?
  • Difference of 2 NSArray's for animated insert/delete in UITableView
  • Use Google Calendar UI but showing only filtered events
  • Using table-of-contents in code?
  • enableviewstatemac=true
  • HTML5: dragover(), drop(): how get current x,y coordinates?
  • Do hash functions exist in nature?
  • OpenGL Diffuse Lighting Shader Bug?
  • How to estimate the contribution of an individual to a software project?
  • Proving (~A -> ~B)-> (~A -> B) -> A in Coq
  • Xquery - Count elements
  • iPhone UIButton addTarget:action:forControlEvents: not working
  • Curried anonymous function in SML
  • Need help on HL7
  • how to turn Bluetooth on/off with J2ME?
  • Subquery using derived table in Hibernate HQL
  • LINQ To SQL error "There is already an open DataReader associated with this Command"
  • how to check-out document in document library programmatically in sharepoint
  • COMET no JS framework links/tutorials?
  • wxPython Frame disable/enable?
  • Help writing database queries for derby?
  • Issues with Trac (installed with BitNami)
  • Using Ghostscript in server mode to convert PDFs to PNGs
  • What's the case when using software licensed under GPL or LGPL
  • Is there any less or more convenient iDoc Script editor for Oracle 10g UCM?
  • What are the most popular RSS readers? (software/web apps)
  • MPICH vs OpenMPI
  • Why are not all texts of my MFC applicatiopn displayed using ClearType?
  • Should I focus on code quality while Rapid prototyping?
  • how to get response in QtWebKit
  • Silverlight - Access the Layout Grid's DataContext in a DataGrid CellTemplate's DataTemplate?
  • is it possible to set specific file extensions as exclusive check out only, with TFS
  • JasperReports: is it possible to use multiple data sources, or if not, to use collections in parameters?
  • Is there a 2d sprite library for webgl?
  • Error: NAND: could not write file /hd2/android-sdk-linux_86/add-ons/google_apis-7_r01/images//system.img, File exists
  • how to configure and use jstl in websphere
  • What does => mean in Ada?
  • Maven best practice for generating artifacts for multiple environments [prod, test, dev] with CI/Hudson support?
  • Maven best practice for generating multiple jars with different/filtered classes?
  • Usage of # in Pascal
  • Generics and polymorphism
  • Concurrent call to conversation
  • polymorphism relates inheritance
  • Maximum values in wherein clause of mysql
  • Forbid developer to commit code because of making weekly build
  • Automatically adjustment of wxPython Frame Size
  • how to import a file into mathematica and reference a column by header name
  • How to integrate junit/pmd/findbugs report into hudson build email?
  • In Symfony, sharing data across subdomains
  • In MediaWiki, is it possible to capture user search terms that don't return results?
  • How to check in what language a program (.exe) has been written. How to view the code?
  • Can I automap a tree hierarchy with Fluent NHibernate?
  • How to adjust the distribution of values in a random data stream?
  • Optimizing SMO with RBFKernel (C and gamma)
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk