Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: what is difference between call stack and stack tace?

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what is difference between call stack and stack tace?

    Hi !
    My doubt is on call stack and stack trace in java.
    Call stack: “The call stack is an internal list of all the methods that are currently executing.”
    Stack trace: ”It is a list of all all the methods in call stack.”
    According to above definitions Stacktrace contains list of all the methods in call stack.
    Then what is the difference between call stack and stack trace?
    Please explain the difference.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,425
    Thanks
    52
    Thanked 2,313 Times in 2,269 Posts

    Default Re: what is difference between call stack and stack tace?

    Where did you get those definitions?
    Those definitions sound like the same thing.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: what is difference between call stack and stack tace?

    Maybe I'm wrong, but I think that the call stack is the list of the methods and the stack trace is the String representation of this list.

  4. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is difference between call stack and stack tace?

    The call stack is the actual data structure in memory while the stack trace is just a representation or snapshot of the call stack...

  5. #5

    Default Re: what is difference between call stack and stack tace?

    A call stack is typically "the current stack of operations" - i.e. while it's running. A stack trace is typically a copy of the call stack which is logged at some sort of failure, e.g. an exception.

  6. #6
    Member
    Join Date
    Sep 2018
    Posts
    32
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: what is difference between call stack and stack tace?

    Definition - What does Call Stack mean?
    A call stack, in C#, is the list of names of methods called at run time from the beginning of a program until the execution of the current statement.

    A call stack is mainly intended to keep track of the point to which each active subroutine should return control when it finishes executing. Call stack acts as a tool to debug an application when the method to be traced can be called in more than one context. This forms a better alternative than adding tracing code to all methods that call the given method. Whenever an exception is thrown anywhere in the user code, the Common Language Runtime (CLR) will unwind the call stack and search for the catch block to determine the specific exception type. If there is no appropriate handler, CLR will terminate the application. Call stack, therefore, is used to tell the execution pointer where to go next.

    Techopedia explains Call Stack
    Call stack is organized as "stack," a data structure in memory for storing items in a last-in-first-out manner, so that the caller of the subroutine pushes the return address onto the stack and the called subroutine, after finishing, pops the return address off the call stack to transfer control to that address.

    In C#, any application begins with a "main" method, which in turn calls other methods. On every call to a method, the method is added to the top of the stack and is removed from the stack on its return to the caller. Also, the scope of a variable declared in a block is determined from the time its value is pushed onto the stack (as part of call stack) until the execution leaves the block when the variable and the call stack are popped off the stack. Thus, the stack maintains both local variables (value types) and the call stack (stack frames), the size of which indicates the complexity of a program.

  7. #7
    Member
    Join Date
    Sep 2018
    Posts
    32
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: what is difference between call stack and stack tace?

    Stack trace is a representation of the call stack. A stack trace is a report of the active stack frames at a certain point in time during the execution of a program. In other words, the call stack is the actual data structure in memory, while the stack trace is a snapshot of said data structure.
    A call stack is typically "the current stack of operations" - i.e. while it's running.

    A stack trace is typically a copy of the call stack which is logged at some sort of failure, e.g. an exception.

    In other words, while you're debugging you will look at the current call stack - but when you look at logs, you'll get a stack trace. At least, that's my interpretation of the terms

Similar Threads

  1. Please Help Java Stack
    By izzahmed in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 25th, 2011, 07:46 AM
  2. stack
    By ridg18 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 22nd, 2011, 12:45 PM
  3. Stack
    By AmyH in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 7th, 2010, 04:04 PM
  4. Stack Order?
    By TimW in forum AWT / Java Swing
    Replies: 2
    Last Post: September 19th, 2009, 08:33 AM
  5. Error of "cannot access InToPost" in 3 and 5 code
    By jaysoncutie in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 25th, 2009, 10:12 AM