<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>What OS is this leak on? I don't think it is anything in the Modula-3 wrappers to pthreads, but please confirm.</div></span></span></span></span></span></span></span></span></div></span> </div><br><div><div>On 3 Jan 2009, at 05:36, Jay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">The pthreads code appears to leak for every thread created, as a result of trying to set stack size.<br>I'll just fix it, once confirmed.<br><br>Setting stack size is basically impossible all around.<br>Both by the user and by "the OS".<br><br>By the user:<br><br>If the user calls into any dynamically linked code he didn't write, he doesn't<br>know what is needed, without a lot of testing, and it can change in time.<br><br>If the user so much as compiles with different flags or a different compiler<br>or targeting a different platform, stack use will change.<br><br>By the OS:<br><br>Same thing -- the OS doesn't know how much stack any user will need.<br> <br><br>Personally I generally practise and recommend minimizing stack usage<br>and using heap instead. However there are large tradeoffs in<br>perf and medium tradeoffs in debuggability (debuggers do a better<br>job of immediately showing the contents of character arrays, instead<br>of pointers, which they don't follow automatically, at least cdb/ntsd/windbg,<br>not sure about the various gdb/dbx/visualstudio).<br> <br><br>A terrible pattern imho, is stuff like<br> char FilePath[some large maximum like 200 or 1000];<br><br>They use up the stack fast, are usually wasteful over-allocations, and sometimes<br> arbitrary capacity-limiting under-allocations. For paths in particular,<br> Win32 advertises two maximums, one of which is wrong, the other of which is<br> suspicous -- 260 and 32K. 32K isn't clearly correct due to the availability of<br> relative opens.<br> Even if 32K is considered correct, it is way too much to allocate "just in case".<br> Better to determine the actual needed size and allocate that.<br> (I think current Cygwin code does just this though -- blow up a bunch of buffers to 32K.)<br> Imho.<br><br>Oh, and the common Unix advertisement of 1024 is also perhaps wrong.<br>You know, what happens if I am using SMB to NT, or to another system with a different max?<br>Do paths beyond 1024 get truncated, or unavailable, or overflow buffers?<br>They can certainly exist.<br>I'll have to try it out sometime.<br><br>In general on disk structures are all "relative" and have no limits for full paths,<br>only usually for individual path elements.<br><br>The stack is generally of relatively small capacity, and when it is exhausted,<br>that is more difficult to detect and recover from, than heap or addressspace<br>exhaustion.<br><br>True, even heap and addresspace can run out, by either being "only" 32bits, or<br>via fragmentation, and are difficult to recover from.<br>I personally don't defend against fragmentation, and it worries me some.<br>It's maybe not a concern in Modula-3 due to compaction, however compaction<br>seems also bad in that it requires larger contiguous memory.<br>Fragmentation is good. Fragmentation is bad..<br><br> - Jay<br><br><br><br><br>> Date: Fri, 2 Jan 2009 11:32:57 +0100<br>> From: wagner@<br>> To: m3devel@<br>> Subject: Re: [M3devel] FW: variations of waitpid..?<br>><span class="Apple-converted-space"> </span><br>> Quoting Jay:<br>><span class="Apple-converted-space"> </span><br>> > (Personally I have seen precious little code that cares about stack<span class="Apple-converted-space"> </span><br>> > size, just seems to somehow get along, combined with the fact that<span class="Apple-converted-space"> </span><br>> > the current Modula-3 pthread code very likely leaks on some<span class="Apple-converted-space"> </span><br>> > platforms attempting to deal with stack size, makes me inclined to<span class="Apple-converted-space"> </span><br>> > just rip out the code..but yeah..just fix the leak...)<br>><span class="Apple-converted-space"> </span><br>> Please don't do that (remove the ability to set stack sizes). I know<br>> that for most of the programs I wrote years ago we had to adapt stack<br>> sizes for threads carefully. That was with user threads though.<br>><span class="Apple-converted-space"> </span><br>> Olaf<br><br></div></span></blockquote></div><br></body></html>