Grasshopper

algorithmic modeling for Rhino

Hey David,

Im having an issue, every time I open gh Im getting the message 'windows explorer has stopped working', which is then followed by, 'windows explorer is restarting'...?

Im also having an issue I cant seem to figure out with a c# component, Im not sure if its an issue in the code or with one of the methods, objects...etc.    

when i slide the values outside of the c# component rhino will crash.

Thanks


Views: 160

Replies to This Discussion

ok, Ive worked out the C# componenet issues, somehow... but i still don't understand why it was crashing Rhino.
It was crashing because the recursion got stuck. It was calling itself over and over again, not making any progress. After a while (usually a few milliseconds) the memory space in your machine that keeps track of which function called the currently executing function, and which function called that function and so on and so forth (this is called the Call Stack) overflowed and shut down the entire application.

When writing recursive functions, it's usually a good idea to put some sort of fail-safe in there to avoid a recursion stack overflow. One popular method is to use a "chicken int". Like so:

public void RecursiveFunction(Object blech, Object blarg, int chicken)
{
if (chicken > 10000) { return; }
// do your thing
RecursiveFunction(blech, blarg, chicken + 1);
}


this way, every function knows how deep it is nested and it can choose to abort based on that information.

--
David Rutten
david@mcneel.com
Poprad, Slovakia


ps. the "chicken" in chicken int obviously refers to the programmer, who is scared his code might not terminate correctly.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service