It is likely that you can replace recursion with iteration which means you won''t have the problem of running out of stack.
Could you show us some simplified code?
weirdest memory problem ever
No I''m fairly sure this cant be replaced by iteration, its a kind of optimized brute force. So it seems the stacks my problem. Is there any solution. Or is my only bet to break the recursion into seperate parts.
-CProgrammer
-CProgrammer
It is likely that you can replace recursion with iteration which means you won''t have the problem of running out of stack.
Could you show us some simplified code?
Could you show us some simplified code?
Manage your own stack inside the function. It''s not that hard of a modification. I''ve heard it called data recursion.
harr! I knew we didn''t learn this for nothing! µ-recursive calculatable = while-program calculatable. That means you can definitely convert to iteration. Even if you have to use a stack datastructure (not the IA32 stack), you won''t need to pass the return address, and you can likely cut out some of the parameters (=> less mem usage). Also, your own stack is much less limited than the system stack, which starts out at 1 MB for your program.
Oh my god, I fixed the problem, and you guys wont believe what it was. Since a MessageBox kept making it crash I put a few file functions in that saved wether the code section was executed(Yes in Release mode what else are you gonna do?). After some time I pinpointed the exact line.
it was something like this:
if(a)
{
delete[] a;
a = 0;
}
I had forgotten to set a to 0 in the constructor of the class.
For some reason windows seemed to be able to recover when not too much memory is used, but when there was a lot allocated before this line crash. Whats more weird the app crashes even if the Messagebox is BEFORE THE TROUBLE LINE and I dont see the textbox.
Geeze its always the same little thing huh.ahhh
Thanks you guys for the help. If I have a stack overflow as the next problem i''ll know what to do Perhaps I''ll prevent this preempitevely now.
-CProgrammer
it was something like this:
if(a)
{
delete[] a;
a = 0;
}
I had forgotten to set a to 0 in the constructor of the class.
For some reason windows seemed to be able to recover when not too much memory is used, but when there was a lot allocated before this line crash. Whats more weird the app crashes even if the Messagebox is BEFORE THE TROUBLE LINE and I dont see the textbox.
Geeze its always the same little thing huh.ahhh
Thanks you guys for the help. If I have a stack overflow as the next problem i''ll know what to do Perhaps I''ll prevent this preempitevely now.
-CProgrammer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement