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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:10:18+00:00 2026-05-15T17:10:18+00:00

I’m just getting started writing a simple web crawler to get info on links

  • 0

I’m just getting started writing a simple web crawler to get info on links we have coming in to our system. I’m using httpclient 4.x. I have about 100 threads running fetching links and doing head requests on them, it works great for the first few hours then it slows to a screeching crawl. I’m not sure if I’m setting up the connection manager properly or not.

here is the code I have to create an httpclient object. Anyone see anything that would raise an alarm with this code block? When I stop the server and restart it everything is as good as new again. During the phase when it’s running slow the memory still looks ok at a steady 500K per process so it doesn’t look like I’m leaking memory.

HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
HttpConnectionParams.setSoTimeout(httpParams, 5000);
ConnManagerParams.setMaxTotalConnections(httpParams, 200);
HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);

// set request params

httpParams.setParameter("http.protocol.cookie-policy", CookiePolicy.BROWSER_COMPATIBILITY);
httpParams.setParameter("http.useragent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");


SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", PlainSocketFactory.getSocketFactory(), 443));

final ClientConnectionManager cm = new ThreadSafeClientConnManager(httpParams,schemeRegistry);

HttpClient httpClient = new DefaultHttpClient(cm, httpParams);

httpClient.getParams().setParameter("http.conn-manager.timeout", 10000L);
httpClient.getParams().setParameter("http.protocol.wait-for-continue", 10000L);

I’m also using this code in a thread to clean up expired connections as mentioned in the docs

final Runnable cleanUp = new Runnable() {
      public void run() { 

        cm.closeExpiredConnections();
        // Optionally, close connections
        // that have been idle longer than 30 sec
        cm.closeIdleConnections(30, TimeUnit.SECONDS);

      }
     };

UPDATE:
I ran visual VM for an hour or so and here’s the memory graph on the remote process, the memory is now used up

http://img64.imageshack.us/f/screenshot20100714at204.png/

  • 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-15T17:10:19+00:00Added an answer on May 15, 2026 at 5:10 pm

    Use VisualVM (it also comes with JDK) and monitor your application for a while with JMX. Also install Visual GC plugin, it offers an inside of what happens with your GC(which might slow down the application a lot if there is not enough memory).

    When it slows down, look at the Threads tab to see how it looks when it comes to locking. Locking or not enough memory(memory leaks) should be the problem in your case.

    If you want to go deeper, I would recommend you YourKit Java Profiler.

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

Sidebar

Related Questions

No related questions found

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.