Stack Size

For an assignment I had to create a postfix calculator, and one of the errors we had to catch was:
if there is more then one integer left in the stack when printing the final result, it needs
to give an error message and exit.
We were provided the implementation and interface for the Stack by our instructor and here is the method he used for toString.
    public String toString() {
     if (empty()) {
         return "Empty Stack";
     } else {
         return recursiveToString(top);
    /* recursive method to print a non-empty stack
     * @param     the starting index in the array
     * @return     a string representing the stack
    private String recursiveToString(IntNode start) {
     if (start == null) {
         return "";
     String separator = "";
     if (start != top) {
         separator = " :: ";
     return recursiveToString(start.getNext()) +
                start.getValue() + separator;
    }Basically if there is more than one integer in the stack it will print it like so:
1 :: 2 :: 3 :: 4
This is what I used to tell if there was more than one integer left in the stack when printing the final results. I used this code:
//Checking for the "::" that the toString method prints between integers
//when there is more than one left in the stack. If there is more the one
//integer left in the stack then give an error and exit.
for(int i = 0; i < intStack.toString().length(); i++) { //looping through the toString
//if there are two colons, consecutively, there is more than one integer in the stack
     if(intStack.toString().charAt(i) == ':' && intStack.toString().charAt(i+1) == ':') {
          System.out.println("Error:\tMore than one integer in final stack. Make sure equations\n\tin " + param[0] + " are valid. Exiting program...");
          System.exit(1);
}Now my question is... is there a better way to do this? Ideally I would like this part to work regardless
of how the toString method formats the integers. Because right now if the toString method was
changed my little check would not work. So is there a way to determine the amount of items in a stack
or a better way to do this.
To give a better understanding of those snippets here is the code as a whole:
import java.util.EmptyStackException;
import java.util.Scanner;
import java.io.File;
public class KinseyAnthony4 {
     public static void main(String[] param) {
          /** Declare new IntLinkedStack Stack Object */
          IntLinkedStack intStack = new IntLinkedStack();
          //Make sure there is only one parameter entered.
          if(param.length == 1) {
               //try to read the file
               try {
                    /** declaring new file object */
                    File calcMe = new File(param[0]);
                    /** declaring new scanner object */
                    Scanner readIt = new Scanner(calcMe);
                    /** declaring int for line number */
                    int line = 1;
                    /** declaring int for first number popped from stack */
                    int top = 0;
                    /** declaring int for second number popped from stack */
                    int next = 0;
                    /** declaring int to hold the result of calculations */
                    int result = 0;
                    //Report current status
                    System.out.println("Reading through " + param[0] + ":");
                    //Use loop to view each line until there are none left
                    while(readIt.hasNextLine()) {
                        /** declaring string that holds current line's content */
                         String lineContent = readIt.nextLine();
                         //Report current line number and it's contents
                         System.out.println("\nLine " + line + ": " + lineContent);
                         //Use for loop to analyze each character in the line
                         for(int i=0; i < lineContent.length(); i++) {
                              //Is it a digit?
                              if(Character.isDigit(lineContent.charAt(i))) {
                                   /** declaring int that holds numeric value of the char */
                                   int pushMe = Character.getNumericValue(lineContent.charAt(i));
                                   //Report what's being pushed on stack
                                   System.out.println(">Pushing " + pushMe + " to stack.");
                                   //Push the value on the stack
                                   intStack.push(pushMe);
                              //It's not a digit
                              else {
                                   //Use a switch statement for computations
                                   switch(lineContent.charAt(i)) {
                                        //Multiplication
                                        case '*':
                                             top = intStack.pop(); //Pop top number
                                             System.out.println(">Popping " + top + " from stack."); //Status
                                             next = intStack.pop(); //Pop next number
                                             System.out.println(">Popping " + next + " from stack."); //Status
                                             result = next * top; //Multiply them
                                             System.out.println(">Calculating " + next + " * " + top); //Status
                                             intStack.push(result); //Push result back onto stack
                                             System.out.println(">Pushing result of " + result + " to stack."); //Status
                                             break;
                                        //Division
                                        case '/':
                                             top = intStack.pop(); //Pop top number
                                             System.out.println(">Popping " + top + " from stack."); //Status
                                             next = intStack.pop(); //Pop next number
                                             System.out.println(">Popping " + next + " from stack."); //Status
                                             result = next / top; //Divide them
                                             System.out.println(">Calculating " + next + " / " + top); //Status
                                             intStack.push(result); //Push result back onto stack
                                             System.out.println(">Pushing result of " + result + " to stack."); //Status
                                             break;
                                       //Addition
                                        case '+':
                                             top = intStack.pop(); //Pop top number
                                             System.out.println(">Popping " + top + " from stack."); //Status
                                             next = intStack.pop(); //Pop next number
                                             System.out.println(">Popping " + next + " from stack."); //Status
                                             result = next + top; //Add them
                                             System.out.println(">Calculating " + next + " + " + top); //Status
                                             intStack.push(result); //Push result back onto stack
                                             System.out.println(">Pushing result of " + result + " to stack."); //Status
                                             break;     
                                        //Subtraction
                                        case '-':
                                             top = intStack.pop(); //Pop top number
                                             System.out.println(">Popping " + top + " from stack."); //Status
                                             next = intStack.pop(); //Pop next number
                                             System.out.println(">Popping " + next + " from stack."); //Status
                                             result = next - top; //Subtract them
                                             System.out.println(">Calculating " + next + " - " + top); //Status
                                             intStack.push(result); //Push result back onto stack
                                             System.out.println(">Pushing result of " + result + " to stack."); //Status
                                             break;
                                        //Invalid Characters
                                        default:
                                             //Ignore them if they're spaces
                                             if(!Character.isSpaceChar(lineContent.charAt(i))) {
                                                  //So if they're not spaces give an error and exit
                                                  System.out.println("Error:\tInvalid character read. Exiting program...");
                                                  System.exit(1);
                                                  break;
                         //Checking for the "::" that the toString method prints between integers
                         //when there is more than one left in the stack. If there is more the one
                         //integer left in the stack then give an error and exit.
                         for(int i = 0; i < intStack.toString().length(); i++) { //looping through the toString
                              //if there are two colons, consecutively, there is more than one integer in the stack
                              if(intStack.toString().charAt(i) == ':' && intStack.toString().charAt(i+1) == ':') {
                                   System.out.println("Error:\tMore than one integer in final stack. Make sure equations\n\tin " + param[0] + " are valid. Exiting program...");
                                   System.exit(1);
                         //Once it passes that check, print the final calculation
                         System.out.println("***The final result is " + intStack.toString() + "***");
                         //Clear the stack for the following loop
                         while(!intStack.toString().equals("Empty Stack")) {
                              intStack.pop();
                         //Increment the line number and loop back
                         line++;
                    //If it's the end of the file, exit
                    System.exit(1);
               //catch invalid postfix equations
               catch(Exception e) {
                    System.out.println("\nError:\tThe " + e + " occured while reading " + param[0] +".\n\tMake sure equations in " + param[0] + " are valid. Exiting program...");
                    System.exit(1);
          //The user entered more than one parameter
          else {
               //Give the error and exit
               System.out.println("Error:\tToo many parameters. One file name parameter is allowed. " + param.length + " were found. Exiting program...");
               System.exit(1);
/* a stack of ints implemented using a linked list of nodes
* @author     Biagioni, Edoardo
* @assignment     lecture 8 and homework 4
* @date     February 6, 2008
class IntLinkedStack implements IntStackInterface {
    /* only need to store a single pointer to the node holding
     * the top of the stack.
     * The pointer is null if the stack is empty.
    private IntNode top;
    /* no-arguments default constructor creates an empty stack */
    public IntLinkedStack() {
     top = null;          // start with an empty stack
    /* @return     whether the stack is empty */
    public boolean empty() {
     return (top == null);
    /* @param     int to push onto the stack */
    public void push(int value) {
     top = new IntNode(value, top);
    /* @return     the top int on the stack */
    public int pop() throws EmptyStackException {
     if (empty()) {
         throw new EmptyStackException();
     int result = top.getValue();
     top = top.getNext();
     return result;
    /* convert the stack to a printable string
     * @return     a string representing the stack
    public String toString() {
     if (empty()) {
         return "Empty Stack";
     } else {
         return recursiveToString(top);
    /* recursive method to print a non-empty stack
     * @param     the starting index in the array
     * @return     a string representing the stack
    private String recursiveToString(IntNode start) {
     if (start == null) {
         return "";
     String separator = "";
     if (start != top) {
         separator = " :: ";
     return recursiveToString(start.getNext()) +
                start.getValue() + separator;
    // simple test
    public static void main(String[] args) {
     IntStackInterface s = new IntLinkedStack();
     System.out.println("before pushing anything, " + s);
     s.push(999);
     s.push(216);
     System.out.println("after pushing 999 and 216, " + s);
     System.out.println("pop returns " + s.pop());
     System.out.println("after popping, " + s);
     // push 100 values
     for (int i = 0; i < 100; i++) {
         s.push(i);
     // now pop them and make sure the same values are returned
     // in LIFO order
     for (int i = 99; i >= 0; i--) {
         int returned = s.pop();
         if (returned != i) {
          System.out.println("error: pop returns " + returned +
                       ", expected " + i);
     s.push(477);
     s.push(381);
     s.push(888);
     System.out.println("after pushing 477, 381, 888, " + s);
     System.out.println("pop returns " + s.pop());
     System.out.println("pop returns " + s.pop());
     System.out.println("pop returns " + s.pop());
     System.out.println("pop returns " + s.pop());
     System.out.println("after popping, " + s);
     /* expected output:
    private class IntNode {
        /* two fields, the first to store the item itself,
         * the second is a pointer to the next node in the linked list.
      * If there is no next node, the pointer is null.
     private int item;
     private IntNode nextNode;
     /* constructor:
      * @param     value, the value for the node
      * @param     next, the next node in the linked list
     public IntNode(int value, IntNode next) {
         item = value;
         nextNode = next;
     /* accessor methods -- since there are no mutator methods,
      * each node is immutable.
     public int getValue() {
         return item;
     public IntNode getNext() {
         return nextNode;
/* an interface to a stack of ints
* @author     Biagioni, Edoardo
* @assignment     lecture 8 and assignment 4
* @date     February 6, 2008
* @inspiration     William Albritton's integer stack and Java's stack class,
*http://www2.hawaii.edu/~walbritt/ics211/stackArray/IntegerStackInterface.java
* http://java.sun.com/j2se/1.5.0/docs/api/java/util/Stack.html
interface IntStackInterface {
    /* @param     string to push onto the stack */
    void push(int value);
    /* @return     the top string on the stack */
    int pop()
     throws java.util.EmptyStackException;
    /* @return     whether the stack is empty */
    boolean empty();
}and this is the file i tested it on:
98-
1 1 +
7 2 /
8 1 1 + /
2 3 * 1 -
5 5 + 2 2 * -
8 2 / 9 3 / +
2 2 * 2 *
1 2 3 1 + * +
2 6 + 3 - 2 *The outcome should be 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Thanks in advance, any help would be appreciated!

AnthonyJK wrote:
Thanks, I'm working on breaking it into methods now.Good.
I also whipped something up,but I currently don't have access to a compiler so there might be errors in it. It's basically the same as what your big main method does, but in a much more readable manner:
public class KinseyAnthony4 {
     * @param a     the first number
     * @param op    the mathematical operator
     * @param b     the second number
     * @return      the outcome of the expression 'a <op> b'
    private static int evaluate(int a, char op, int b) {
        switch(op) {
        case '+': return a+b;
        case '-': return a-b;
        case '*': return a*b;
        case '/': return a/b;
        default: throw new RuntimeException("Unknown operator: "+op);
     * @param calcMe    the File in which the expressions are stored.
     * @return          the expressions as an array of Strings.
    private static String[] readLinesFrom(File calcMe) throws FileNotFoundException {
        List<String> lines = new ArrayList<String>();
        Scanner readIt = new Scanner(calcMe);
        while(readIt.hasNextLine()) {
            String line = readIt.nextLine();
            line = line.replace(" ", ""); // remove all white spaces
            lines.add(line);
        return lines.toArray(new String[]{});
     * @param param     one parameter needed: the file containing the expressions
    public static void main(String[] param) throws FileNotFoundException {
        if(param.length != 1) {
            System.out.println("usage: java KinseyAnthony4 FILENAME");
            System.exit(666);
        String[] expressions = readLinesFrom(new File(param[0]));
        for(String exp: expressions) {
            System.out.println("\nLINE = "+exp);
            IntLinkedStack stack = new IntLinkedStack();
            for(char ch: exp.toCharArray()) {
                if(ch >= '0' && ch <= '9') {
                    int digit = Character.getNumericValue(ch);
                    System.out.println("push: "+digit);
                    stack.push(digit);
                } else {
                    int b = stack.pop();
                    int a = stack.pop();
                    System.out.println("pop: "+a);
                    System.out.println("pop: "+b);
                    System.out.println("calculating: "+a+" "+ch+" "+b);
                    int temp = evaluate(a, ch, b);
                    System.out.println("push: "+temp);
                    stack.push(temp);
            int result = stack.pop();
            System.out.println("***The final result is "+result+"***");
}Now as to your problem: you see that the pop() method throws an exception? You can wrap the necessary lines of code between *try { ... } catch(...) { ... }* statements to catch the exception when an expression in malformed. I hope that makes a bit sense to you, if not, post back.
Good luck.

Similar Messages

  • Cannot increase the stack size

    Hi,
    We have a program which gives a StackOverflowError. Trying the increase the stack size using command line options does not work. A simple program shows that the stack is the same size, whatever option we set.
    This is the program:
    class StackOverflowTest
    public static int counter = 0;
    public static void main(String[] a)
    try {
    sub();
    } catch (StackOverflowError e)
    System.out.println("recursive calls: "+counter);
    public static void sub()
    counter++;
    sub();
    We tried several -Xss (and -Xoss) settings: 600K, 2048K, 4M but got the same recursion deep: 16683 (with Eclipse), or 16689 (command line).
    We used Windows XP.
    Do you have any clue?
    Many thanks,
    Zsolt

    Oh good, they seem to have broken the forum formatting again.
    ====================================================================================================================
    Bug ID:     4362291     Stack size argument ignored (-Xss and -ss)
    ====================================================================================================================
    public class StackOverflowTest {
        public static int counter = 0;
        public static final void main(String[] a) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        sub();
                    } catch (StackOverflowError e) {
                        System.out.println("recursive calls: "+counter);
            }).start();
        public static final void sub() {
         counter++;
         sub();
    /code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Change the default stack size in the java.exe file

    Does anyone know how to change the default stack size of the jvm?
    I'm having problems with my stack. Is there anyway I can change it. I found a tool editbin.exe which is shipped with Visual c++, however I don't have the tool.
    Thanks,
    William

    I am using JNI to connect java with a C++ application.
    When calling the C++ appliction, STACK_OVERFLOW
    happends. I tried java -Xss<size> to increase the
    stack size, but failed.This has nothing to do with the above question.
    Does anyone knows why?Probably because the java parameter specifies the java stack size and not the C++ stack size.

  • How can I increase the hard limit of the stack size?

    Hi,
    My process gives an error of segmentation fault (SIGSEGV) that is caused because the stack limit is reached. I have a doubt about how to increase the stack size. I have tried change it with "ulimit - hard" but this size is 65532kb, and is very low for my process. How can I increase the hard limit?
    Thanks.

    When last I checked, the kernel had a fixed stack size limit.
    Do you have the source code to this application? If so, [see this Tiger stack size article|http://homepage.mac.com/eric.c/hpc/contents/documentation/How%20to%20in crease%20the%20stack%20size%20on%20Mac%20OS%20X.pdf], and specifically have a look at the +ld -stack_size+ mechanism; rebuild the code with a bigger limit.
    Entirely FWIW, this question would be more typical over in the developer forums or maybe in the Unix forum if you don't have Apple developer access. Better audience for application development and for software-related questions over there.

  • Stack size for native thread attaching to JVM

    All:
    I have a native thread (see below, FailoverCallbackThread) that attaches to the JVM and does a Java call through JNI. The stack size for the native thread is 256KB.
    at psiUserStackBangNow+112()@0x20000000007a96d0
    at psiGuessUserStackBounds+320()@0x20000000007a8940
    at psiGuessStackBounds+48()@0x20000000007a8f60
    at psiGetPlatformStackInfo+336()@0x20000000007a9110
    at psiGetStackInfo+160()@0x20000000007a8b40
    at psSetupStackInfo+48()@0x20000000007a5e00
    at vmtiAttachToVMThread+208()@0x20000000007c88b0
    at tsAttachCurrentThread+896()@0x20000000007ca500
    at attachThread+304()@0x2000000000751940
    at genericACFConnectionCallback+400(JdbcOdbc.c:4624)@0x104b1bc10
    at FailoverCallbackThread+512(vocctx.cpp:688)@0x104b8ddc0
    at start_thread+352()@0x20000000001457f0
    at __clone2+208()@0x200000000030b9f0
    This causes stack overflow in Oracle JRockit JVM. (It does not cause overflow with Oracle Sun JDK.) Is there a recommended stack size for this use case for JRockit? Is there a way to compute it roughly?
    Platform Itanium 64 (linux)]
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    BEA JRockit(R) (build R26.4.0-63-63688-1.5.0_06-20060626-2259-linux-ia64, )
    mp

    How do I found default heap size, stack size for the
    thread, number of threads per jvm/process supported ?The threads is OS, OS install and jvm version specific. That information is also not useful. If you create the maximum number of threads that your application can create you will run out of memory. Threads require memory. And it is unlikely to run very well either.
    The default heap size and stack size are documented in the javadocs that explain the tools that come with the sun jdk.
    and how the above things will vary for each OS and how
    do I found ? Threads vary by OS, and OS install. The others do not (at least not with the sun jvm.)
    If I get "OutOfMemoryError: Unable to create new native thread" Most of the time it indicates a design problem in your code. At the very lease, you should consider using a thread pool instead.
    I found in one forum, in linux you can create maximum
    of 894 threads. Is it true ?Seems high since in linux each thread is a new process, but it could be.

  • Why ulimit  fails for stack size in Sol 10 update 11 with project settings?

    Hi,
    The following command fails on Solaris 10 update 11 platform. It works fine with update 10. Something has changed in update 11. Any ideas?
    ulimit -Ss 1 (or any number for that matter)
    /bin/ksh: ulimit: exceeds allowable limit
    We have the following setting in project as well.
    process.max-stack-size=(basic,137988707188736,deny)
    process.max-stack-size=(priv,137988707188736,deny)
    Thanks for your help in advance.
    Samy

    Here are the values from the project command if you anyone is wondering
    update 10
    ======
    cat /etc/release
    Oracle Solaris 10 8/11 s10x_u10wos_17b X86
    Copyright (c) 1983, 2011, Oracle and/or its affiliates. All rights reserved.
    Assembled 23 August 2011
    prctl -n process.max-stack-size $$
    process: 10189: /bin/ksh -i
    NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
    process.max-stack-size
    privileged 125TB max deny -
    system 125TB max deny -
    update 11
    ======
    cat /etc/release
    Oracle Solaris 10 1/13 s10x_u11wos_24a X86
    Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
    Assembled 17 January 2013
    prctl -n process.max-stack-size $$
    process: 24776: /bin/ksh -i
    NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
    process.max-stack-size
    basic 125TB - deny 24776
    privileged 125TB - deny -
    system 125TB max deny -

  • Need of changing the default stack size permanently as reported by ulimit -

    Hi All,
    In order to install proper 11gr2 on solaris 10 I need to make change of stack size permanently.
    My current ulimit -s is 8192 but according to the oracle 11g installation docs (Configure Shell Limits) they recommend you change the value reported by ulimit -s to be 32k (or 32768).
    I can change this value usiing "ulimit -s 32768" but after reboot of sever this value alwayes change back to old value(8192).
    I tried to do that in /etc/projects but not able to make this permanent, How to make stak size permanently in solaris 10.
    I am on ...
    Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC

    Hi;
    I suggest please review:
    http://serverfault.com/questions/21417/how-to-set-ulimits-in-solaris-10
    It seems that parameter will lost after server reboot. SoThe above settings are not permanent and will be lost after the reboot of the server. To make the changes permanent you need to set this in the respective user profile file. (For ex : .bash_profile on linux)
    Please review:
    Connecting Using: sqlplus "/ as sysdba" Fails with ORA-12547 with Lower Ulimit Setting [ID 878375.1]
    Regard
    Helios

  • Default stack size vs. -Xss option

    Hi,
    What the default stack size?
    That is, if you use the -Xss<size> option, it will set the stack
    size to <size>, but what is the default. I've searched and only
    found one posting that says it is 256k.
    http://forum.java.sun.com/thread.jsp?forum=256&thread=40530
    Is that correct? Since this is a JVM option, is it platform
    dependant? In that case, what would it be on Win2k and Solaris?
    We are serializing graph objects and getting a StackOverflowError
    on occassion. There is a well known bug about this:
    http://developer.java.sun.com/developer/bugParade/bugs/4152790.html
    Thanks.
    --- Patrick

    Hi,
    It depends on version and OS.
    In Solaris there is in addition the OS restriction in ulimit
    or maxssiz in HP.
    hurricane% ulimit -a
    time(seconds) unlimited
    file(blocks) unlimited
    data(kbytes) unlimited
    stack(kbytes) 8192
    coredump(blocks) unlimited
    nofiles(descriptors) 4096
    vmemory(kbytes) unlimited
    Workaround - Use "ulimit -s 2048" in bash shell or "limit stacksize 2048" in tcsh to limit the initial thread stack to 2 MB.
    http://java.sun.com/docs/hotspot/VMOptions.html
    Check the link for the Solaris defaults.

  • RangeError: Maximum call stack size exceeded

    Dear all,
    we are executing and EDGE project in a Samsung SmartTV.  In more powerful models (more memory and cpu) the execution is correct. but in some old TV models we receive the following  message:
    File:   file://c/........../EDGE_006/edge_includes/edge.2.0.1.min.js
    Line No:  135
    Error Detail: RangeError: Maximum call stack size exceeded.
    It seems that this happens depending on the complexity of the EDGE project, as for some simple projects it works.
    we would like to adjust our EDGE project for this less powerful models modifiying animations and simplifying complexity, but we dont know where to start (which animations to remove, etc.)
    Or if there are some parameters in the edge API to adjust in order to increase performance in low memory browsers.
    Thank you in advance,
    Luis

    sunil-online wrote:
    > I am calling an external DLL and running it in the UI thread. How much
    > stack space is available when they are on separate threads or on the
    > UI thread?
    >
    > The problem is that I am getting seemingly random crashes while
    > running this VI and after I quit labview after stopping and uninit-ing
    > my DLL.
    Unless you know this DLL is using exceedingly lots of stack (at least
    several dozens of MB) for whatever obscure reasons it is very unlikely
    that running out of stack space is causing your problem. More likely
    either the DLL does something nasty to a data pointer passed in to it or
    you made an error in setting up the call to the DLL.
    For instace if the DLL expects strings or array pointers to be passed in
    they need to
    be allocated by the caller (here LabVIEW) and you need to
    tell LabVIEW to do that in the diagram code.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Call Stack Size

    Is there a way to increase the call stack size of LabVIEW or to know
    when it has been exceeded?
    Thanks.

    sunil-online wrote:
    > I am calling an external DLL and running it in the UI thread. How much
    > stack space is available when they are on separate threads or on the
    > UI thread?
    >
    > The problem is that I am getting seemingly random crashes while
    > running this VI and after I quit labview after stopping and uninit-ing
    > my DLL.
    Unless you know this DLL is using exceedingly lots of stack (at least
    several dozens of MB) for whatever obscure reasons it is very unlikely
    that running out of stack space is causing your problem. More likely
    either the DLL does something nasty to a data pointer passed in to it or
    you made an error in setting up the call to the DLL.
    For instace if the DLL expects strings or array pointers to be passed in
    they need to
    be allocated by the caller (here LabVIEW) and you need to
    tell LabVIEW to do that in the diagram code.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Difference for method stack size in release and debug builds

    Hi,
    I have a question regarding the method stack size. Running my project in the debug version works fine. Running the same project as release causes a StackOverflowError (60 entries). Is there any difference in the allowed stack size?
    If I split the method (in which the error occurs) into two separate methods and call them sequentially, this works in the release build as well.
    I am using Flex SDK 3.4. This is reproducable on Win and Mac.
    Cheers
    Philipp

    Hi,
    I have a question regarding the method stack size. Running my project in the debug version works fine. Running the same project as release causes a StackOverflowError (60 entries). Is there any difference in the allowed stack size?
    If I split the method (in which the error occurs) into two separate methods and call them sequentially, this works in the release build as well.
    I am using Flex SDK 3.4. This is reproducable on Win and Mac.
    Cheers
    Philipp

  • BUG: Unable to increase stack size in OJVM

    Hi,
    I have a complex ADF Faces page (jspx) that has reached the level of complexity that I can reliably cause the JVM to die when running the page with:
    Fatal error: Cannot find class java/lang/StackOverflowError
    Process exited with exit code -1.when running within JDeveloper. I have tried adding
    -Xms1024m -Xmx1024m(yes, I know an outrageous stack size) to the project run properties, and it still crashes. However, if I change to the server JVM instead of ojvm, it works fine, even with a much smaller stack, although the default stack size will crash as well.
    So,
    1). Shouldn't -Xms and -Xmx work for OJVM? If not, this is going to be a pain when I need to debug, as OJVM rocks for that.
    2). Is there some way to configure ADF/OC4J so that I won't bomb like this? I'm guessing that the XML document (JSPX) is big enough that it's causing the XML parser to blow up. Just a guess however.
    Thanks,
    John

    It's unclear if the problems discussed happen after OJC compiles, or Javac compiles, or both. We have uncovered a bug in the compilation of jspx files using OJC. There is a chance that this bug fix will fix the problems mentioned. Email me at keimpe.bronkhorst AT oracle.com if you want to try out a patched OJC. This is not an OJVM fix, so if you compile with Javac, I can't help you at this time.
    Keimpe Bronkhorst
    JDev team

  • Error stack size

    Hi,
    i have build a package framework which in exceptional situations uses an encapsulated raise_application_error method with the
    -add to error stack- option. In combination with
    -speaking- messages it seems as if i am now running against the error stack size border. What i see is that the primarily generated errors are lost.
    Is it possible (and recommended) to increase the size and does anyone now how to do this ? (I still have to use 8.1.7)
    Thanks in advance,
    Bjoern

    First of all: you should mention it when you cross-post, to prevent people from wasting their time providing an answer already given in the other site.
    https://community.jboss.org/thread/223626
    Doing a google for "The stack size specified is too small, Specify at least 160k" gives plenty of reason to believe it is not really a 'problem', but simply a requirement of the JVM; how and why can only be answered by the developers of said JVM, you're not going to find them here because this is a user to user forum. And this isn't any different under Java 7.
    So other than downgrading, I don't see how you're going to make any impact. I would do the Google yourself, collect the search results that all indicate that the startup scripts are adjusted to the wishes of the JVM and present that to the vendor to shut them up. Anything more - well good luck getting an official statement from Oracle.

  • Checking stack size

    I have written a JNI app and it seems to work fine, but processing with very large files I run out of stack space.
    I have solved this issue for the moment by changing the stack size with the -Xss param to java but this is not the ideal issue because with even bigger files I still will have issues.
    So, I have 3 questions:
    1. Is there any way (in the c++ dll) to query the total stack size ?
    2. Is there any way to determine free (available) stack size ?
    3. Is there any way to increase the stack size when the dll is already running (if it starts to get low)
    I look forward to your thoughts
    Ding

    I have written a JNI app and it seems to workfine,
    but processing with very large files I run out
    of
    stack space.
    That suggests that you have a design problem.
    As a guess you are using recursion. Start by
    unrolling the recursion code to produce a
    non-recursive solution.ood Guess but there is no recursion in my code :-)
    While I am always trying to optimize my design, in
    this case I am constrained by 3rd party c libraries
    that are using very large multi dimensional arrays of
    doubles that are neccessary for lots of complicated
    math doing triangualtion of satellite data. So, I
    have no control over how much memory they want to
    consume.
    ood Guess but there is no recursion in my code :-)
    Then it is unclear as to what you think a good solution would entail.
    Do you intend to just to keep retrying the processing step with ever increasing stack sizes? Will that not impact the processing time? Why not just start with a larger stack size? And if the stack size just continues to grow because the file sizes are continuing to grow then what?
    While I am always trying to optimize my design, in
    this case I am constrained by 3rd party c libraries
    that are using very large multi dimensional arrays of
    doubles that are neccessary for lots of complicated
    math doing triangualtion of satellite data. So, I
    have no control over how much memory they want to
    consume.
    One solution would be to create a C app, not a java one. Find the maximum amount of stack space that you can allocate via a C app and still operate (this depends on what happens with the file itself.) The output goes to a file.
    Your java app just starts that in a separate process space.
    >>
    >
    I was referring to the native C stack, used within
    the c++ dll, for which the java VM starts via the
    -Vss flag. I know the initial total as I am setting
    it at runtime. I just wanted to print the value from
    within the dll. #2 (below) is more important
    though.
    That would depend on your OS and compiler.
    2. Is there any way to determine free(available)
    stack size ? This is the part I was mostly hoping for an answer
    to, as I need to communicate with the parent java app
    if the stack space gets too low, instead of just
    allowing the dll to crash when it runs out
    That is a two part question. You want to know the size and you want to know if it gets 'too low'.
    You suggested that this is all stack based processsing. So unless you have C methods that are called by the library and in addition it is recursive in nature then this is not possible. There is no point where you could detect it.
    You can analyze the file yourself and compute a size before you start processing. But if that is what you are doing then you should do it first and let the java app know the result.
    Other than that most OSes allow you to catch 'system exceptions' (which might or might not be actual C++ exceptions.) One of these would be generated when the stack overflows.
    You then convert into something that java understands.
    For example in Windows there is a function that allows you to set up system exceptions so that they cause a C++ exception to be thrown. You would then catch this exception and convert it into a java exception.
    That lets you know that it didn't work but then what?
    For example in windows you can create a custom stack for the dll but only when the dll loads (so far as I know.) So to restart this you would have to unload the dll and that means that you will have to have everything wrapped in a custom class loader (which is the only way to cause a dll to be unloaded.)
    Not to mention that in my experience the windows function that I mentioned above doesn't necessarily always catch everything.
    >>>
    >>
    No. The VM must be restarted.if that is true, It i a bummer :(You can however, on most OSes, increase the stack size for the shared library. This is done on start up of the shared library. To resize it however means that the shared library must be reloaded. And the only way you can do that in the Sun VM is with a class loader.

  • Thread stack size problem

    Hi all,
    I am having a multithreaded application and the threads are created with 256 KB thread stack size.
    This application was developed in windows(32 bit) now ported to Solaris 8.
    The same was failed while running because of stack overflow and then the thread stack size is increased to 257 KB then the application is working fine.
    Please anybody suggest me how the same application is working fine in windows with lesser thread stack size?
    Please also suggest me any tool which can be used to get the thread stack details while running the application.
    Regards,
    Velan.R.S

    Hello Farhan
    We had similar issues and we tackled it in a few ways. First you may want to track down what type of memory issues you are hitting, permgen verse heap
    Simple Tomcat updates I would look into
    set your inital memory pool to something like 256 MB
    Up your max to 2 or 3 GB
    if you are having permgen issues i would set the following in your tomcat java options
    -Xrs
    -XX:MaxPermSize=512M
    -XX:+CMSClassUnloadingEnabled
    -XX:+UseConcMarkSweepGC
    -XX:+CMSPermGenSweepingEnabled
    -Djava.awt.headless=true
    I would also look into increasing your treads and adding compression to your 8080 listener
    Tomcat Vertical Scale
    Once you have done the simple tomcat updates if you still have issues you may want to add more tomcat instances and use use a proxy server to load balance them. You can use Apache with mod_proxy or mod_jk. or even a more enterprise solution with an appliance like BigIP f5 or Cisco CSS.
    I would really recommend front your tomcat(s) with Apache and doing a split deploy. Then fronting your apache servers with an appliance load balancer. James Rapp has a great article on how to do this. 

  • How to set the stack size for alchemy application?

    Anybody know how to set the stack size for alchemy application?
    If you know, please tell me how to adjust the stack size for alchemy application?

    Hi,
    The stack size is set as public const gstackSize in the alchemy generated code.  You can see this if you build with ACHACKS_TMPS set.  The default is one megabyte.
    One way to change the stack size is to use llvm-dis to disassemble avm2-libc/lib/avm2-libc.l.bc, generating avm2-libc.l.ll, modify the constant, and then use llvm-as to recompile your modified library and overwrite the old one.  These utilities should be in your path if alchemy is set up.

Maybe you are looking for

  • DTW - Business Partner Master Data

    Hello, i'am having some problem concern to import of marter data of BP, in  OCPR - ContactEmployees and CRD1 - BPAddresses. I'am using ODBC and using the query structure like in the .scv files. I do the import and DTW don't give error message and do

  • ABAP server proxy-External Debugging

    I have a server ABAP proxy implementation in a R/3 where i m sending message from XI, I want to debug the the ABAP Proxy using External debugging (http breakpoint), Pls tell me if it is mandatory to: 1. login in R/3 (for debugging) using the same use

  • Nokia 5800XM Iplayer problem

    I updated my phone from v20 to 21, iplayer was working fine before the update, but now whenever i click on a program real player says "unable to play media clip"? is there a fix for this? becasue i cant find anthing about it on the interweb (atleast

  • Parse oracle sql file

    Good day. I need to develope little app for executing *.sql files. How can I parse sql file to retrieve oracle response for each statement while executing. (ex. sqlplus)??

  • Cannot access local copy of NAS

    I can logon to my NAS, however my MacBook pro keeps prompting me to logon to the local copy of the NAS.  Then rejects my username and password combo.  I no longer know what that combo is.  Is there a way to reset this?