changing the stack size in DLL
-
I have an ActiveX control which displays models containing a huge number of facets in OpenGL. I use recursion during the building of the models and unfortunately am overflowing the stack. How does one increase the size of the stack in a COM/ATL dll? I've tried the compiler option '/F' and linker option '/STACK' without any luck. Is there a way to do this programmatically? Thanks in advance! Emil
-
I have an ActiveX control which displays models containing a huge number of facets in OpenGL. I use recursion during the building of the models and unfortunately am overflowing the stack. How does one increase the size of the stack in a COM/ATL dll? I've tried the compiler option '/F' and linker option '/STACK' without any luck. Is there a way to do this programmatically? Thanks in advance! Emil
As far as i recall, the stack size is not related to a DLL, its the process including the DLL that is deciding on its stack size. Depending on the amount of information stored on the stack, it would probably be better if you kept only a pointer to a struct with the info you need at each level of recursion. You could event count the recursion level and keep some information into an array that is dependant on the recursion level. Here are a few points you might want to investigate too. How many levels deeps are you getting into ? Are you sure you're not simply entering an infinite recursion which does overflow the stack. Is the recursive function having too many parameters, could you simplify these parameters and pass in a struct pointer ? Are there too many local variables in my recursive function ? Every time you enter a function, there is a number of bytes being reserved in the stack, each parameter passed to a function could be taking some stack space so if you recurse on a function that requires 40 bytes for its parameters it can add up quickly. Also, local variables do take space on the stack. Having a recursive function with "char somearray[512]" isnt convenient in a recursive function since on each recursion level, 512 bytes will be reserved for that level.