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 4125582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:53:18+00:00 2026-05-20T23:53:18+00:00

Im building a application that needs to poll a webserver alot. Right now i

  • 0

Im building a application that needs to poll a webserver alot. Right now i create a recursive method that requests the server and when response is returned it starts all over again, i might put in a sleep in between later.

Now because i need this intensive request polling. I would like to optimize the actual code to do as little work for each request as possible.

I figured i could create a HttpGet (request) and DefaultHttpClient onces and just reuse these instances over and over again.
See http://pastebin.com/qa7k7uEY

The problem is im receiving OutOfMemory errors after like 20 requests.

See error log here http://pastebin.com/58Dhh7L4

Is there a better way of handling this many requests??

  • 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-20T23:53:18+00:00Added an answer on May 20, 2026 at 11:53 pm

    It’s probably better to post your code in the question itself.

    That being said, the problem is that none of your requests can be garbage collected, as none of them ever pass out of scope; you are constantly building the call stack upwards without exiting the poll method.

    You should use some sort of delaying mechanism that would allow you to exit your method while still scheduling some work to be done. Something like this should suffice:

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            poll();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an application that needs to use a web server like a file
I'm building an application that needs to run through an XML feed but I'm
I'm building an application that needs to compile on both Windows and Linux. The
We are currently building an application that needs to communicate to some IBM WebSphere
i'm building an application that needs a random unique id for each user not
I'm building a socket application that need to shuffle a lot of small/medium sized
I am building an application in Cocoa that uses a local Ruby on Rails
I'm looking into building a distributed application and would like some advice on the
I'm building a conforming and validating XML parser in C++ and trying to make
I'm a novice-to-intermediate JavaScript/jQuery programmer, so concrete/executable examples would be very much appreciated. My

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.