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 1 Time in 1 Post

    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. The Following User Says Thank You to me_shankara For This Useful Post:



  3. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 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.

  4. The Following User Says Thank You to Norm For This Useful Post:


  5. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 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.

  6. The Following User Says Thank You to curmudgeon For This Useful Post:


  7. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    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...

  8. The Following User Says Thank You to rikitiktak For This Useful Post:


  9. #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.

  10. The Following User Says Thank You to priya456 For This Useful Post:


  11. #6
    Member
    Join Date
    Sep 2018
    Posts
    32
    Thanks
    0
    Thanked 9 Times in 6 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.

  12. The Following User Says Thank You to meenal For This Useful Post:


  13. #7
    Member
    Join Date
    Sep 2018
    Posts
    32
    Thanks
    0
    Thanked 9 Times in 6 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

  14. The Following User Says Thank You to meenal For This Useful Post:


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, 07: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, 09:12 AM