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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:44:53+00:00 2026-06-07T21:44:53+00:00

In my java web application, I have a single background-worker thread, which requires a

  • 0

In my java web application, I have a single background-worker thread, which requires a lot of stack space, because it runs a really complex workflow using the activiti workflow engine and groovy script tasks.

Currently I need to set the JVM Xss setting as high as 16MB on a 64bit Java and Tomcat, to circumvent any StackOverflowErrors. If the error occurs the stack trace is really huge (several hundred lines long) but it all happens inside the engine, so I can’t really do anything about it.

Now my question is: is there a way to increase the stack size of a single thread at runtime?

I’d like to lower the JVMs default Xss settings for all threads in the application to 512k, which I know is enough and only run the worker with 16M.

The Java API provides some information on this topic for a constructor of the Thread class:

public Thread(ThreadGroup group,
              Runnable target,
              String name,
              long stackSize)

but it mentions, that the behaviour is not guaranteed ([1]) and I didn’t find any information, if it would work on windows.

Also, if the stack space of one thread cannot be increased and I have to specify 16MB as default value, what would be the consequences of having such a high setting? Would that mean that every new thread would reserve 16MB of memory upon initialization (i.e. 200 threads * 16MB: 3,2 GB)?

As far as I can tell from jconsole and taskmgr, the memory footprint doesn’t seem to have changed much since the increase of the Xss settings, but maybe I’m missing something.

Any help or clarification would be appreciated.

[1]: http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String, long)

  • 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-07T21:44:55+00:00Added an answer on June 7, 2026 at 9:44 pm

    Its worth nothing that -Xss on HotSpot specifies the maximum size, not the size it will use. The size used is based on usage so if you specify this unreasonably large it will waste virtual memory (which can be a problem on a 32-bit JVM) but it won’t waste physical memory. If you have a 64-bit JVM, there is little disadvantage in making the largest you want any thread to be.

    Also, if the stack space of one thread cannot be increased and I have to specify 16MB as default value, what would be the consequences of having such a high setting? Would that mean that every new thread would reserve 16MB of memory upon initialization (i.e. 200 threads * 16MB: 3,2 GB)?

    Each thread will use this much virtual memory. On a 32-bit JVM, you will run out of address space even if you actually use very little memory. On a 64-bit JVM, your limits is in the TB and only the stack actually used will use main memory.

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

Sidebar

Related Questions

For our Kunagi Java web application we have a signed kunagi.jar file which contains
I have a Java-JSF Web Application on GlassFish, in which I want to use
Hi I have a page in my java/jsp based web application which shows list
I have a java web application running on tomcat, and will use single sign
I have a Java web application at my work and I'd like simplify how
I have a Java based web-application using Java Server Faces and Facelets. I am
I have a Java Web Start application. I specify the resource (jars, images, etc)
Is it possible to have a Java/J2EE web application integrate/communicate with SharePoint to load,
I am working on a small Java EE web application. The problem I have
I have web application written in java using Eclipse. It has just one servlet

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.