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: how to find stack size in java

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to find stack size in java

    hello gyus is there any way to find out the current stack size of any program?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,387
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: how to find stack size in java

    Sounds like a job for Thread.currentThread().getStackTrace().

    Thread (Java Platform SE 6)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to find stack size in java

    but i think this works to find out the stack trace i.e the usage of stack.but i have to find out the remaing stack size of code.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,387
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: how to find stack size in java

    Quote Originally Posted by aditiya View Post
    but i think this works to find out the stack trace i.e the usage of stack.but i have to find out the remaing stack size of code.
    What does that even mean? Give us an example.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to find stack size in java

    My code is a single thread program. if i allocate the stack size of 1024K so how would i find when main thread executes how much stack has been consumed and how much is still available? and if i do not allocate the stack size so how much stack size will allocated by JVM by default?

  6. #6
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: how to find stack size in java

    Thread moved to Java Theory & Questions
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  7. #7
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    471
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: how to find stack size in java

    Quote Originally Posted by aditiya View Post
    My code is a single thread program. if i allocate the stack size of 1024K so how would i find when main thread executes how much stack has been consumed and how much is still available? and if i do not allocate the stack size so how much stack size will allocated by JVM by default?
    Google is your friend. I don't normally act as a Google front-end, but 'java stack size' gives this as the first item.

Similar Threads

  1. stack Palindrome , java
    By Faha in forum Object Oriented Programming
    Replies: 1
    Last Post: May 3rd, 2011, 04:20 PM
  2. What am I doing wrong with this stack? Java Programming?
    By babe20042004 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 1st, 2011, 12:19 PM
  3. Limit File Size or Request Size
    By tarek.mostafa in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: June 11th, 2010, 07:21 AM
  4. Custom Java stack class (with generics) problem
    By TBBucs in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 7th, 2010, 01:25 AM
  5. Can we increase the stack size for JVM ?
    By prasanna in forum Java Theory & Questions
    Replies: 4
    Last Post: August 4th, 2009, 03:17 PM