<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.6000.16850" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px">
<DIV>In my applications, I added code to accept a command line parameter for increasing the stack size. Internally, I call the procedures from the Thread interface to increase the stack size. I had to do this to avoid running out of stack, esp. when using Trestle/FormsVBT. I found that I had to multiply the stack size by a factor of 7 for most of my stuff to work. Note that this increase applies to new threads, not to the mainline thread. I don't know of a way to increase the mainline thread stack while it is running. </DIV>
<DIV> </DIV>
<DIV>If there is a change to the default stack size, anyone who does similar tricks will need to modify their code, or their shortcuts, or scripts to avoid making the stack too big.</DIV>
<DIV> </DIV>
<DIV>See the code snippet below:</DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2> (* stack *)<BR> IF pp.keywordPresent("-stack")<BR> THEN (* *)<BR> TRY (* *)<BR> stackMult := pp.getNextInt(min := 1, max := 100);<BR> EXCEPT<BR> | ParseParams.Error => (* *)<BR> pp.error("A number in the range [1..100] must be specified as\n"<BR> & "the stack size multiplier after the -stack option.\n");<BR> END; (* try *)<BR> END; (* if *)<BR> IF stackMult > 1<BR> THEN<BR> WITH default = Thread.GetDefaultStackSize(),<BR> desired = default * stackMult,<BR> increase = desired - default<BR> DO<BR> PutText("Increasing default stack size by a factor of " &<BR> Fmt.Int(stackMult) & " (" & Fmt.Int(default) & " >>> " &<BR> Fmt.Int(desired) & ").\n");<BR> Thread.IncDefaultStackSize(increase);<BR> END; (* with *)<BR> WITH default = Thread.GetDefaultStackSize()<BR> DO<BR> PutText("Thread stacks are now " & Fmt.Int(default) & " bytes.\n");<BR> END; (* with *)<BR> END; (* if *)</FONT></DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV>Randy Coleburn<BR><BR>>>> Jay K <jay.krell@cornell.edu> 7/27/2009 11:24 AM >>><BR><BR>I don't think this is a stack overflow but I will try that.<BR>We should probably drastically increase the defaults.<BR>Like make them match whatever the underlying platform uses, or just make <BR> sure that unless the user intercedes, that we don't either.<BR><BR><BR>The whole notion of a limited size stack is pretty flawed imho.<BR>And much worse if you engage in reducing it from the default.<BR>How much stack do I need to leave for fopen to work?<BR>What do I do when I run out of stack? On NT you can detect and handle it, but it is too tricky.<BR>Personally I try to use very little stack, and don't use recursion - if I must use a "heap allocated stack" (e.g. std::stack<> in C++).<BR>I understand though that the machine stack is tremendously faster than anything heap-based (at least in non-gc environments, gc heap alloc can be fast, if you don't mind the extra work for the gc to later clean it up..and if the usage is actually lifo...)<BR><BR><BR>Granted, if I'm "just doing a bunch of math" and don't call into code I don't control, then it becomes more tenable. Still hard to pick a size that is portable, though multiplying by sizeof(void*) helps.<BR>What if I use TRY? That uses a highly platform-specific and often fairly large amount of stack.<BR><BR><BR>- Jay<BR><BR><BR>----------------------------------------<BR>> Date: Mon, 27 Jul 2009 16:53:08 +0200<BR>> From: wagner@elegosoft.com<BR>> To: m3devel@elegosoft.com<BR>> Subject: Re: [M3devel] the formsedit crash<BR>><BR>> Quoting Tony Hosking :<BR>><BR>>> Not sure if doing it that way works. Current default stack size set in<BR>>> ThreadPThread.m3 is 4096 * ADRSIZE(Word.T). You'll need to try<BR>>> changing it there.<BR>><BR>> There used to be a procedure IncreaseDefaultStackSize. IITR we needed<BR>> that for several M3 applications on some platforms several years ago.<BR>><BR>> But probably we should also set the default for a target platform<BR>> so that all our own applications are able to run.<BR>><BR>> Olaf<BR>> --<BR>> Olaf Wagner -- elego Software Solutions GmbH<BR>> Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany<BR>> phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95<BR>> <A href="http://www.elegosoft.com">http://www.elegosoft.com</A> | Geschäftsführer: Olaf Wagner | Sitz: Berlin<BR>> Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194<BR>><BR></DIV></BODY></HTML>