Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implement a stack

Status
Not open for further replies.

spcheng7

Programmer
Feb 27, 2002
7
HK
Hi all,
I want to implement a flood fill program for image. But
each time I run the program, it said out of stack. Someone
tells me that it is because the VB stack is not large, my
program runs out stack space and then program crashes.
Can I implement a larger stack by myself ? what should
do ? Any reference on the Internet ?
THx

Tony
 
If you're running out of stack space, then you may be in a runaway recursive situation. Check and see if you a a routine which calls itself, and calls another routine which in turns call back to the original routine. It could get quite deep A call B, B calls C, C calls D, D calls E, and then E calls A, and it starts over again.



Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Out of Stack Space is usually caused by "cascading" events triggered by faulty event handling i.e. programmer error. Do you handle any events and if so, what other events including the event you are in do you trigger? Step through the code/ Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
When you get the message "Out of Stack Space" select debug and then Ctrl_L to look at the call stack in the VB IDE.
You should then see where the recursion is occuring.

Very simple demo
Start a new form
In Form_Load, put Form_Load
 
If you actually decide to implement a Stack of your own design, I would have thought it could be done by writing an object based on the collection object. I'd be surprised if there isn't a customer stack in the language though...

 
There is (at least in the dim recesses of my memory) a setting in VB to reserve additional or specific amounts of "Stack Space". On the other hand, the 'crowd' does have a point - the usual reason for the error is ' ... error betweeen the seat and the key board ... "

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
You could avoid the problem altogether by using the ExtFloodFill API function...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top