Grasshopper

algorithmic modeling for Rhino

Hallo all

 

I am working on a heuristik in order to place as many objects in an area so that they can be seen from multible points.

Therefor I need to generate as many possible placements as possible.

 

Unfortunatly my VB script allways runs out of memory (200000+ polylines...)

 

I define all my used variables at the beginning of the script.

I only use ByRef when passing variables to a function.

 

And still during computation it builds up memory usage.

 

Is the garbage collection running while the vb script is computed or only at the end ?

If is there any way to call for garbage collection?

 

thx

 

Richard

Views: 392

Replies to This Discussion

Hi Richard,

 

the garbage collector is always running. Calling it specifically won't solve any problems. If you're running out of memory, you probably just have too much data stored. There's some ways to try and tackle this:

 

  1. Switch to Rhino5 64-bit. Then you won't run out of memory, though it might get incredibly slow if you have to start paging.
  2. Store your data elsewhere. Either use a DataBase or write data to the disk and only store minimal information about where to find it.
  3. Redesign your code to use less memory. Sometimes this is simple impossible, sometimes there's a small bug you missed, sometimes there's an optimization you can apply.

 

"I define all my used variables at the beginning of the script."

I don't see how this will affect anything at all.

 

"I only use ByRef when passing variables to a function."

This, too, probably doesn't matter. If you're passing reference-types then it doesn't get duplicated anyway, and if you're passing value-types then they'll only require memory while that function is running. Unless your functions are deeply recursive this won't make a difference.

 

I suppose the most important question is, why do you need to keep all those polylines around? If you're trying to find the best solution, why don't you discard sub-optimal solutions as you go?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

THX David for the replay. 

 

"I suppose the most important question is, why do you need to keep all those polylines around? If you're trying to find the best solution, why don't you discard sub-optimal solutions as you go?

 "

And here is my problem. I erase polygones from the list as soon as they get irrelevant, but still the memory keeps on building up.

 

Pseudocode:

PolylineList ... Stores all Polylines

tempPolylineListList ... Stores the part of the List that is worked on

 

While tempPolylineListList is not empty Do

tempPolylineList = PolylineList.getRange(0,n)

... doSomething with the tempPolylineList

remove all Polylines from PolylineList that are not part of a possible Solution

Loop

 

tempPolylineList = PolylineList.getRange(0,n) ' does this duplicate the entries or is it only referencing the entries?

 

Is there any way to monitor the behaviour of the PolylineList / tempPolylineList other then the print() command in the vb script button?

 

 

 

 

 

I won't be able to find memory bugs in pseudocode. You'll need to post some code that actually runs and duplicates the problem.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service