Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:01:08+00:00 2026-06-05T18:01:08+00:00

When sending uncontrolled amounts of TextWebSocketFrames to a simple Netty WebSocket echo server implementation

  • 0

When sending uncontrolled amounts of TextWebSocketFrames to a simple Netty WebSocket echo server implementation (slightly modified version of the implementation found in the examples package), without waiting for a client side sync() on the ChannelFuture, the heap memory usage on the server is growing exponentially until it finally goes out of memory.

Testcase: the client does not wait until the actual bytes have been written, nor does it wait for the server to “echo” the text back to the client before writing the next text frame

for (int i = 0; i < 10000000; i++) {
    ch.write(new TextWebSocketFrame("Message #" + i));
}

When observing the yourkit memory profiler (15 seconds into the test with approx. 20.000 frames written), the number of BigEndianHeapChannelBuffer objects has grown excessively.

BigEndianHeapChannelBuffer 284,509 (objects) 9,104,288 (shallow size) (after ~30.000 frames sent within 10 second window)

On the server side a big pile up can be observed mainly from BigEndianHeapChannelBuffers and CompositeChannelBuffers objects which are never cleaned nor garbage collected (which might not be possible as references are held). I’m guessing this has something to do with the (single) worker thread not being able to write the downstream “echo” response to the client channel because it’s busy processing the rapidly incoming requests from the client

Is there a way to prevent/throttle this (accidental denial of service) on the server side?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:01:10+00:00Added an answer on June 5, 2026 at 6:01 pm

    In Netty, most I/O operations are asynchronous. Therefore, writing thousands of messages without waiting for the previous writes to be finished will get you an OutOfMemoryError. To avoid that, I prefer having a counter variable to count the number of pending writes. For example:

    private final AtomicInteger pendingWrites = new AtomicInteger();
    
    ...
    while (pendingWrites.get() < MAX_PENDING_WRITES) {
      pendingWrites.incrementAndGet();
      ch.write(msg).addListener(new ChannelFutureListener() {
        ...
        pendingWrites.decrementAndGet();
        if (pendingWrites.get() < MAX_PENDING_WRITES) {
          // resume writing here
        }
      }
    }
    

    Alternatively, you can use ChunkedWriteHandler which essentially does the same job.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when sending packet to openfire using Smack, i get error remote-server-not-found(404) . Can anyone
For sending HTML document information such as content-encoding , charset , date , last-modified
Im sending out an order conformation for recipients via the simple mail function built
Im sending mails from a web application running on a glassfish server, which was
when sending data to a php server through android I cam across this error:
When sending emails to distribution lists, the lists themselves are found within the Global
Im sending a simple url request using the following url: urlString = [NSString stringWithFormat:
I am sending a message with special characters to the server, since server cannot
Im sending files to my server from my android device, and would be great
While sending some list of records to HTML I found my page to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.