Stack limits query - windows dlls
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Nov 26, 2002
- 410 views
I have recently stopped a problem which went along the following lines: windows (or win32lib) calls onpaint(1) -- some lengthy graphics stuff onpaint calls doEvents doEvents calls onkeydown onkeydown calls onpaint(2) -- user has zoomed ... onpaint(3) ... onpaint(4) ... of course, onpaint(1)..(3) will check whether to continue and just return, without doing any more graphics stuff, but only after doEvents returns. So if the user (me) zooms and zooms and zooms, before (any of) the graphics drawing gets finished, the stack just grows and grows until it goes bang. The Euphoria interpreter does not have this problem running pure Eu code - I've just tested it to over 1,000,000 recursive calls and it just gets a bit slower, but the windows dlls I think have a much smaller limit, (128K?) and crash. I made onkeydown count how many outstanding calls it had made to onpaint and ignore any further attempts to zoom when it reached a certain number, until that is, they had finished & it is safe to resume. Stopped the problem quite definitely anyway (invalid page fault in module KERNEL32.DLL at 015f:bff71459) So after all that, my question is simple: what would a sensible limit be? Or instead, should I be detecting that onpaint is still running, so instead of calling it, set appropriate flags, safe in the knowledge that control will eventually return to the statement following the doEvents call, so onpaint can loop back to the start? Pete