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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Out of stack error

Status
Not open for further replies.

Kleinen

Programmer
Dec 6, 2001
13
0
0
BE
I have a program that at startup must fill a treeview. However one branch of the treeview is getting very huge. In fact so huge that I get an "Out of stack" error.

Is there some way in VB that I can change the stack size?

TIA
 
Are you using recursion to fill the tree?

That's where people usually get the "out of stack space" error.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
yes I am using recursion to fill the three
 
Then you likely have some uncontrolled recursion.

I would put logging code into every function that you call when building the tree, and when you get the out-of-stack error, you can examine the log for out of control recursion.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
you could also follow the code step by step with the little red circle thingys. (click to the right of a line & it will automatically debugg when it gets there)
 
Or.. you could set breakpoints like ferretrunner says. But I've found that when tracking recursion problems down on a form, the act of debugging causes problems as focus changes from your program to the VB IDE, and back again.

You can minimize this problem by running on a PC that has dual monitors (VB on one, program under test on the other one). Or you instrument your code like I suggested earlier.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Problem solved. I changed the code a little so that the recursive part of the filling of the treeview is less extended.

Thanks for the suggestions
 
One thing I've found is that, especially with the treeview, is to populate a branch only when it is expanded. Why populate a whole tree view if they only go down one branch?
When you populate a branch put in a child node for each element you add. This node is a dummy node that will be removed when you do the real populating but will cause its parent to have the + - box. Explorer used to behaive like this. If yo want the newer behaivor you'll have to populate 1 level lower then what is visible.

Both these problem solve the recursion problem as you only go into the routine when a branch is expanded.


Hope I've been helpful,
Wayne Francis

If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top