Results 1 to 5 of 5
  1. #1
    protonus is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default How to set a stack size. -Xss doesn't work

    Hi,
    Simple program:

    public class Stack {

    static int a;

    static void f(){
    a++;
    f();
    }

    public static void main(String[] args){
    a=0;
    try{f();}
    catch(StackOverflowError e)
    {System.err.print(e.getClass() + " a= " + a);}
    }
    }


    always throws StackOverflow error for the same value of a.
    regardless I run the program as java -Xss1k Stack or java -Xss1024K Stack

    My understanding is the larger stack the longer the program should run.

    What I am missing?

    Thank you for your help
    Last edited by protonus; 06-27-2008 at 12:12 AM.

  2. #2
    pao
    pao is offline Member
    Join Date
    Jun 2008
    Posts
    43
    Rep Power
    0

    Default

    Try it like this: -Xms1024 -Xmx2048

    Those options set the initial memory allocation and the maximum memory allocation, read the java documentation to see examples.

    java - the Java application launcher

  3. #3
    protonus is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default

    Hi,
    Xms and Xmx set a heap size not a stack size.
    I tested them on jre1.5 and jre1.6 - no impact on my program behaviour.

    I just noticed that -Xss doesn't work on Java5 only. It works on Java6.

    So it looks like a bug in jre 1.5.

    Thank for your help.

  4. #4
    pao
    pao is offline Member
    Join Date
    Jun 2008
    Posts
    43
    Rep Power
    0

    Default

    Sorry about that, I didnt even know you could set the available stack memory, I only ever set the heap size. In fact thats the first time I have even encountered xss. Apologies!

  5. #5
    protonus is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default

    Me too. I also have never used xss before.
    There is nothing to apologize for.
    You pointed me on Xms i Wmx swichtes I also never used before
    so I learned something new too.
    Thank's again.

Similar Threads

  1. Making a stack from a LinkedList
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:28 PM
  2. Stack not popping
    By bugger in forum New To Java
    Replies: 2
    Last Post: 01-28-2008, 05:59 PM
  3. Stack Trace
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-10-2007, 06:29 PM
  4. Help with heap and stack
    By coco in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 03:21 PM
  5. Creating a stack with data
    By ai_2007 in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •