Gradually slowing performance with Rhino.Compute

Dear community,

While using Rhino.Compute to pair a fast Grasshopper script with a python optimisation script, I realize that the time taken per iteration is slowly becoming longer. The grasshopper script takes about ~1 second to run (in GH environment itself) and the optimisation script iterates it about 600 times.

I am unsure of what is the root cause of this but I suspect that there is memory being cached somewhere that might not be needed. Below is a plot of available memory and cpu process tracked using the python library / method: “psutil.virtual_memory()” and “psutil.Process(os.getpid()).memory_info()”. Top left plots the time taken per iteration and shows that there is a gradual increase in time taken per iteration.

I hope that somebody can explain to me what is the cause of it and how can I force a ‘clear memory cache’ if it is the root problem. My current work around is to restart Rhino.Compute server on Visual Studio after every optimisation run. Thank you in advance!

1 Like

Sorry for the off topic.
Could you explain how did you load the psutil module?
Thank you

Hi, I followed this forum:


using tools like the psutil module are only helpful to detect a potential problem. But without proper code profiling it is very hard to identify the root cause. There are plenty of possibilities why things do not work.
It is even possible that you see normal behavior. But most likely it is something about your own code what is causing the problem. Causing a memory leak can easily be overseen, if you use static/global data collections (e.g. lists) which are not cleared on a repeating task, such as “iterating” over a solution. But without seeing any code, it is impossible to give you a helpful answer.