Click to See Complete Forum and Search --> : running out of memory
skapta
June 16th, 2007, 12:03 PM
I am working on this mfc app., it reads a segy format file that is about 550mb and creats an ascii file out of it and I pass a pointer of this file to a cube creation algorithm and subsequently this cube will be displayed.
First problem, reading segy ie real slow and when it completes reading, then when I pass the pointer to cube generating algorithm , here there is a stack overflow. How shall I resolve this sluggishness issue and out of memory thing. Any ideas
Appreciate your help
Thanks
Zachm
June 17th, 2007, 07:44 AM
Can't really tell for sure without seeing the code, but probably the memory problem (sluggishness) and the stack overflow are 2 disconnected problems.
Stack overflow usaully occurs when using excessive recursive function calls. The best workaround is to convert the recursive algorithm into an iterative one. If you lack the time to implement the iterative algorithm, there are some project settings that allow enlarging the call stack(google it, I don't remember exactly what settings :() - this won't solve the general problem, only allow higher threshold - it might solve YOUR current problem.
As for the sluggishness - if you handle ~500 MB of memory simultaneously and lack the appropriate RAM, this means, at least on Windows, that the excessive memory will come from the Page File (A.K.A hard disk !) and would make the program very very sluggish.
The solution will be either to enlarge your RAM or develop a method for handling the data by chunks (e.g. read X MB of data, handle it, read the next X MB of data, handle it, and so on...).
Best of luck,
Zachm
MrViggy
June 18th, 2007, 01:21 PM
Stack overflow usually occurs when using excessive recursive function calls. The best workaround is to convert the recursive algorithm into an iterative one. If you lack the time to implement the iterative algorithm, there are some project settings that allow enlarging the call stack(google it, I don't remember exactly what settings :() - this won't solve the general problem, only allow higher threshold - it might solve YOUR current problem.
Or, declaring large variables on the stack (like 'int myArray[1000000];' ).
Viggy
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.