weirdest memory problem ever

Started by
15 comments, last by CProgrammer 20 years, 2 months ago
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?
Advertisement
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
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?
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.
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3
Thanks Wassenberg
-CProgrammer
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

This topic is closed to new replies.

Advertisement