Thread: Stack of main function

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    12

    Stack of main function

    I need to find out stack of main function ...

    Like while we create a thread, we have stack base and stack size...

    So if I assume my main is also a thread in itself, It will have some stack.

    How can I find out limits of this stack?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I've heard 2 Mb mentioned before, but the only two ways to find out are:

    1) Check the compiler doc's, or
    2) Write a very simple program with just a main function, that uses up increasing amounts of stack space, until your program fails from lack thereof.

    That amount may change with different systems, having different amounts of free RAM.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Although I've never done it, I think you can use getrlimit for this purpose, in Linux. In windows there will be functions for that as well, though I don't know which.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM