How to change stack size?

Discussion in 'C Programming' started by Jensen Somers, Jun 5, 2007.

  1. Hi,

    Is it possible to change the stack size of a DLL from within the source
    code? When using threads you can specify the size of the stack you want
    the thread to use, but since my application doesn't use threads I'm
    looking for another solution.

    Source code I haven't written but which I use creates a structure
    containing 4 double arrays of almost 30k. I know this is big but it's
    required and I cannot change anything about that.

    At the moment I change the stack size via the project solution of the IDE
    I'm using and it works for me, but when I ship the .dll and .lib file to
    someone else he too has to change the stack size in the project solution
    of his IDE. This is something I would like to avoid since it's possible
    the required stack size might change in the future and I don't want to
    bother the users of the DLL with that.

    Regards,
    Jensen
     
    Jensen Somers, Jun 5, 2007
    #1
    1. Advertising

  2. In article <>,
    Jensen Somers <> wrote:

    >Is it possible to change the stack size of a DLL from within the source
    >code?


    What's a stack? What's a DLL?

    >When using threads you can specify the size of the stack you want
    >the thread to use, but since my application doesn't use threads I'm
    >looking for another solution.


    What are threads?

    >Source code I haven't written but which I use creates a structure
    >containing 4 double arrays of almost 30k. I know this is big but it's
    >required and I cannot change anything about that.
    >
    >At the moment I change the stack size via the project solution of the IDE
    >I'm using and it works for me, but when I ship the .dll and .lib file to


    What's an IDE? What's a .dll file? What's a .lib file? What's a
    "project solution of the IDE"?

    >someone else he too has to change the stack size in the project solution
    >of his IDE. This is something I would like to avoid since it's possible
    >the required stack size might change in the future and I don't want to
    >bother the users of the DLL with that.



    Your question is sounding suspiciously system-specific; I would suggest
    that you ask in a newsgroup pertaining to whatever operating system
    you are using. C itself does not use any of the terms I pointed out
    (no, not even "stack" -- there are C implementations which do
    not use stacks), but those terms are perhaps used in some specific
    implementations.
    --
    "law -- it's a commodity"
    -- Andrew Ryan (The Globe and Mail, 2005/11/26)
     
    Walter Roberson, Jun 5, 2007
    #2
    1. Advertising

  3. On Tue, 05 Jun 2007 19:22:14 +0000, Walter Roberson wrote:

    >
    > Your question is sounding suspiciously system-specific; I would suggest
    > that you ask in a newsgroup pertaining to whatever operating system you
    > are using. C itself does not use any of the terms I pointed out (no, not
    > even "stack" -- there are C implementations which do not use stacks),
    > but those terms are perhaps used in some specific implementations.


    I know, at the moment I focus on MS Windows since the Linux
    implementation of the library uses threads and doesn't have this problem
    anymore.
    If I ask this in an OS specific newsgroup people point me to the C
    newsgroups and at the end I don't know where to ask anymore.

    Regards,
    Jensen
     
    Jensen Somers, Jun 5, 2007
    #3
  4. "Jensen Somers" <> schrieb im Newsbeitrag
    news:...
    > On Tue, 05 Jun 2007 19:22:14 +0000, Walter Roberson wrote:
    >
    >>
    >> Your question is sounding suspiciously system-specific; I would suggest
    >> that you ask in a newsgroup pertaining to whatever operating system you
    >> are using. C itself does not use any of the terms I pointed out (no, not
    >> even "stack" -- there are C implementations which do not use stacks),
    >> but those terms are perhaps used in some specific implementations.

    >
    > I know, at the moment I focus on MS Windows since the Linux
    > implementation of the library uses threads and doesn't have this problem
    > anymore.
    > If I ask this in an OS specific newsgroup people point me to the C
    > newsgroups and at the end I don't know where to ask anymore.

    If someone points you to comp.lang.c for this question (s)he simply wrong.

    Bye, Jojo
     
    Joachim Schmitz, Jun 5, 2007
    #4
  5. In article <>,
    Jensen Somers <> wrote:
    [earlier]

    >>>Is it possible to change the stack size of a DLL from within the source
    >>>code? When using threads you can specify the size of the stack you want
    >>>the thread to use, but since my application doesn't use threads I'm
    >>>looking for another solution.



    >On Tue, 05 Jun 2007 19:22:14 +0000, Walter Roberson wrote:


    >> Your question is sounding suspiciously system-specific; I would suggest
    >> that you ask in a newsgroup pertaining to whatever operating system you
    >> are using.


    >I know, at the moment I focus on MS Windows since the Linux
    >implementation of the library uses threads and doesn't have this problem
    >anymore.
    >If I ask this in an OS specific newsgroup people point me to the C
    >newsgroups and at the end I don't know where to ask anymore.



    Well, for what it's worth, my off-topic answer to your question is NO.

    http://support.microsoft.com/kb/932909

    The maximum stack size of a thread is not determined by an
    individual ISAPI, DLL, or ASP component that is running inside
    the process. The maximum stack size of a thread is configured by
    the executable file of the process.


    http://msdn2.microsoft.com/en-us/library/aa461430.aspx

    (on use of a /F compiler option to set the program stack size)

    Other ways to set the stack size

    Using the /STACK linker option.
    Using EDITBIN on the .exe file.


    Notice the lack of listing of any API option.


    But you should consider my "NO" answer to be low quality and unproven,
    as I never develop in Windows, and Microsoft's site contradicts itself
    regularily (or to be more charitable, that I might have only found
    older documentation and possibly XP or Vista has a way to do it.)

    My answer was derived entirely from a bit of googling of
    site:microsoft.com with keywords set stack size

    If you rely on my answer for a question of this importance to you,
    then you would be making a mistake. You need something system specific
    to MS Windows, and the only reason I keep a Windows system around
    is to drive my printer.
    --
    I was very young in those days, but I was also rather dim.
    -- Christopher Priest
     
    Walter Roberson, Jun 5, 2007
    #5
  6. In article <>,
    CBFalconer <> wrote:
    >Jensen Somers wrote:
    >>
    >> Is it possible to change the stack size of a DLL from within the
    >> source code? When using threads you can specify the size of the
    >> stack you want the thread to use, but since my application doesn't
    >> use threads I'm looking for another solution.

    >
    >The C standard doesn't mention DLL nor a stack. Thus you are
    >off-topic. Try a newsgroup that deals with your system.


    I assume the word 'newsgroup' doesn't appear in the C standard either.
    Thus, you are off-topic.

    I would imagine that it would be easy enough to build a concordance of
    the words found in the C standard, and then to write a newsgroup scanner
    that would check each post for compliance with said concordance. The
    scanner would then, of course, post an appropriate response to the
    newsgroup, either pointing out the off-topic words (thereby rendering
    CBFalconer redundant) or, in the extremely unlikely event that all words
    passed, would say something like "Good Job!! You are officially on-topic!"

    I would not be surprised to find that one or more of the regulars have
    already done this. If not, get on it!
     
    Kenny McCormack, Jun 6, 2007
    #6
  7. Jensen Somers

    jacob navia Guest

    Jensen Somers wrote:
    > Hi,
    >
    > Is it possible to change the stack size of a DLL from within the source
    > code? When using threads you can specify the size of the stack you want
    > the thread to use, but since my application doesn't use threads I'm
    > looking for another solution.
    >
    > Source code I haven't written but which I use creates a structure
    > containing 4 double arrays of almost 30k. I know this is big but it's
    > required and I cannot change anything about that.
    >
    > At the moment I change the stack size via the project solution of the IDE
    > I'm using and it works for me, but when I ship the .dll and .lib file to
    > someone else he too has to change the stack size in the project solution
    > of his IDE. This is something I would like to avoid since it's possible
    > the required stack size might change in the future and I don't want to
    > bother the users of the DLL with that.
    >
    > Regards,
    > Jensen


    The stack size is allocated at startup. It is by default 1MB so it is
    difficult to understand what is your problem... 30K should not make
    a big difference.

    I am speaking about 32 bit windows of course. Are you using 16 bit
    systems?
     
    jacob navia, Jun 6, 2007
    #7
  8. In article <>,
    CBFalconer <> wrote:
    >jacob navia wrote:
    >> Jensen Somers wrote:
    >>>
    >>> Is it possible to change the stack size of a DLL from within the
    >>> source code? When using threads you can specify the size of the
    >>> stack you want the thread to use, but since my application doesn't
    >>> use threads I'm looking for another solution.
    >>>

    >... snip ...
    >>
    >> The stack size is allocated at startup. It is by default 1MB so it
    >> is difficult to understand what is your problem... 30K should not
    >> make a big difference.
    >>
    >> I am speaking about 32 bit windows of course. Are you using 16 bit
    >> systems?

    >
    >Once more, this is off-topic, and you should have simply referred
    >him to a suitable news-group. I'm in a bad mood today.


    Geez. Words just fail me.
    You see, there are these things call lives. You can get one (yes, even
    you). There is also this thing called sunshine. It is out there,
    waiting for you to go out and enjoy it.
     
    Kenny McCormack, Jun 6, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sunny
    Replies:
    5
    Views:
    2,115
    CBFalconer
    Aug 17, 2006
  2. Surinder Singh
    Replies:
    1
    Views:
    1,206
    Richard Bos
    Dec 20, 2007
  3. Casey Hawthorne
    Replies:
    3
    Views:
    1,096
    Flash Gordon
    Nov 1, 2009
  4. Debajit Adhikary
    Replies:
    36
    Views:
    2,303
    Andre Kaufmann
    Feb 10, 2011
  5. Sam Roberts
    Replies:
    1
    Views:
    227
    Yukihiro Matsumoto
    Feb 11, 2005
Loading...

Share This Page