• Advertisement

Archived

This topic is now archived and is closed to further replies.

weirdest memory problem ever

This topic is 5127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im going nuts here. I have an app that works great with small values as input but crashes with larger ones. When however I add a textbox command somewhere in the algorithm it always crashes no matter where I add the textbox. Its like the program is so unstable it cant handle the textbox. Geeze what kind of problem could this be. -CProgrammer

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Fruny
Array bounds overrun.


Is it possible that Array bounds have been overrun, the app doesnt crash but then crashes upon calling MessageBox?

-CProgrammer

Share this post


Link to post
Share on other sites
quote:
Original post by CProgrammer

Is it possible that Array bounds have been overrun, the app doesnt crash but then crashes upon calling MessageBox?

-CProgrammer



Yes, it is, because you may have trampled on some important memory related to it when you overran the array.

-Mezz

Share this post


Link to post
Share on other sites
quote:
Original post by CProgrammer
Oh and could such an effect be caused by using delete instead of delete[]


depends on whether you should be using delete[] instead of delete

Share this post


Link to post
Share on other sites
Hi! CProgrammer

I think I can help you.

You can''t allocate more memory than the stupid Windows XP Allocated Memory Limit.
So if the Total Allocated memory is 182504 kB and your Limit is 206108 kB you can''t alloate a memoryblock that is bigger than 206108-182504 = 23604 kb.
You can solve this like I did, set the minimum virtual memory limit to 4096 MB and maximum to 4096 MB. But the bad is that the game may not work on other computer.
Or you can try allocate many small memory blocks, that will increase the memory Limit, until you have allocated equal the amount memory you need. Then free it and allocate the big memoryblock. But I haven''t tried this.

I hope this helps you.

- DataWigge

Share this post


Link to post
Share on other sites
datawigge: Thanks, I think you just helped me majorly.
Actually my programm uses a lot of memory. Furthermore it crashes when a recursive function is executed for large numbers, so it calls itself more often and saves a larger single array. If what your saying is true I can search until I day and not find anything, phew. What solution is there. By the way I have 1GB ram but if windows limits than that doesnt matter. Is there a limit to the size of an array and can my app somehow tell windows that I need more memory.
Thanks for any advice on how to solve this.
-CProgrammer

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Manage your own stack inside the function. It''s not that hard of a modification. I''ve heard it called data recursion.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement