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

  • SEARCH
  • Home
  • 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 6184821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:36:12+00:00 2026-05-24T01:36:12+00:00

I used a while loop to fetch message from Amazon SQS. Partial code is

  • 0

I used a while loop to fetch message from Amazon SQS. Partial code is as follows:

ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
while (true) {
    List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();

     if (messages.size() > 0) {

             MemcachedClient c = new MemcachedClient(new BinaryConnectionFactory(), AddrUtil.getAddresses(memAddress));

             for (Message message : messages) {

                 // get message from aws sqs
                 String messageid = message.getBody();
                 String messageRecieptHandle = message.getReceiptHandle();
                 sqs.deleteMessage(new DeleteMessageRequest(myQueueUrl, messageRecieptHandle));

                 // get details info from memcache 
                 String result = null;
                 String key = null;
                 key = "message-"+messageid;
                 result = c.get(key);

             }
             c.shutdown();
          }
       }

Will it cause memory leak in such case?
I checked using “ps aux”. What I found is that the RSS (resident set size, the non-swapped physical memory that a task used) is growing slowly.

  • 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-05-24T01:36:13+00:00Added an answer on May 24, 2026 at 1:36 am

    Sorry, but I don’t see here code to remove message from the message queue. Did you clean the message list? In case that DeleteRequest removes message from the queue then you try to modify message list which you itereate.

    Also you can get better memory usage statistic with visualvm tool which is part of JDK now.

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

Sidebar

Related Questions

Using C# (or VB.NET) which loop (for loop or do/while loop) should be used
I used many different browsers while I was coding for a new site (Firefox,
I have used IPC in Win32 code a while ago - critical sections, events,
I'm having this code from http://bash.cyberciti.biz/guide/While_loop , used to read line by line from
I want to replace and optimize an extensively used while-loop that generates list values
Does anybody know what tool used while podcasts were recorded here: http://www.asp.net/mvc/application-development/ For example
I have 2 radio buttons and I used mootool while loading as window.addEvent('domready', function()
While I used to VB 6 like the back of my hand, it has
I've used strpbrk() occasionally while doing low-level string work in C, but I've never
I used to be confusing quite a while : Confusion on Unicode and Multibyte

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.