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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:10:54+00:00 2026-05-11T22:10:54+00:00

I have a Java web application that works a lot with file conventions. I

  • 0

I have a Java web application that works a lot with file conventions.
I am using Tomcat 6 as my servlet container. When many requests are submitted, Tomcat becomes very memory hungry. I wonder how I can fine-tune tomcat to reduce the memory consumption.
I am also considering changing my servlet container.
What do you suggest?

  • 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-11T22:10:54+00:00Added an answer on May 11, 2026 at 10:10 pm

    You can limit the accepted/operational connection numbers in the conf/server.xml configuration.

    Have

    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="16" minSpareThreads="1"/>
    

    and

    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" 
               />
    

    or

    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" 
               maxThreads='16'/>
    

    in the config file and this should brake you.

    Edit: Based on your comment you could move the processing into dedicated thread pool sized according to your CPU count (Runtime.getRuntime().availableProcessors()) (see ExecutorService and Executors.) Then you could apply a bounded LinkedBlockingQueue to throttle the number of pending tasks (don’t forget to specify a RejectedExecutionHandler to do the blocking add when the queue gets full).

    Edit 2: Added links to the classes. There you find some samples.

    Edit 3: A sample method I used in a project.

    /**
     * Creates a new thread pool based on some attributes
     * @param poolSize the number of worker threads in the thread pool
     * @param poolName the name of the thread pool (for debugging purposes)
     * @param priority the base priority of the worker threads
     * @param capacity the size of the task queue used
     * @return the ExecutorService object
     */
    private ExecutorService newPool(int poolSize, 
    String poolName, final int priority, int capacity) {
        int cpu = Runtime.getRuntime().availableProcessors();
        ExecutorService result = null;
        if (poolSize != 0) {
            if (poolSize == -1) {
                poolSize = cpu;
            }
            if (capacity <= 0) {
                capacity = Integer.MAX_VALUE;
            }
            result = new ThreadPoolExecutor(poolSize, poolSize, 
                    120, TimeUnit.MINUTES, 
                    new LinkedBlockingQueue<Runnable>(capacity), 
            new ThreadFactory() {
                @Override
                public Thread newThread(Runnable runnable) {
                    Thread t = new Thread(runnable);
                    t.setPriority(priority);
                    return t;
                }
            }, new RejectedExecutionHandler() {
                @Override
                public void rejectedExecution(Runnable r,
                        ThreadPoolExecutor executor) {
                    if (!executor.isShutdown()) {
                        try {
                            executor.getQueue().put(r);
                        } catch (InterruptedException ex) {
                            // give up
                        }
                    }
                }
            });
        }
        return result;
    }
    

    And you could use it this way:

    ExecutorService exec = newPool(-1, "converter pool", Thread.NORM_PRIORITY, 500);
    servletContext.setAttribute("converter pool", exec);
    

    And in your servlet

    ExecutorService exec = (ExecutorService)servletContext
    .getAttribute("converter pool");
    
    exec.submit(new Runnable() {
        public void run() {
            // your code for transformation goes here
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Categories extend the original class, but they don't subclass it,… May 12, 2026 at 12:54 pm
  • Editorial Team
    Editorial Team added an answer Haven't tested this, but it's something like: RewriteRule \.php$ -… May 12, 2026 at 12:54 pm
  • Editorial Team
    Editorial Team added an answer "0:0:0:0:0:0:0:1" is the IPv6 loopback address as defined in RFC… May 12, 2026 at 12:54 pm

Related Questions

At our shop, we are maintaining roughly 20 Java EE web applications. Most of
This question is about a Java JTree or a Window .Net Tree (Winforms) or
I work at a company with a large SAP investment, and we also have
I am currently doing some work for a company that runs a legacy web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.