title: Calculating Stack memory being used on Java
body: <p>I'm using drools and <a href="http://activiti.org/" rel="nofollow">activiti</a> to evaluate some rules. The problem is that activiti uses recursion and i'm getting StackOverFlowError, when we have a lot of rules (this is not an infinite loop/recursion, increasing the stack size solves the problem).</p>
  
  <p>1) Can I monitor the actual stack size being used (using JvisualVm or any other tool)?</p>
  
  <p>2) Can I estimate by the method stack (counting the amount of methods in the current executing thread) what is the required stack size per thread so I will not get the StackOverFlowError?</p>