Lag with Excessive Surface Generations

I’ve come to realize that when my plugin needs to generate a lot of surfaces (using methods like NetworkSurface or CreateThroughPoints), it starts to slow down after a couple iterations.

This lag is more visible when a more complicated surface is being created - sometimes if I wanted to generate about 30 highly complex surfaces, the plugin would create the first two within a minute but then it would gradually take longer to do the rest (I waited a whole day for this to finish).

After generation, each surface is added to a List, and the process repeats.

What is causing this increasing lag? How can I fix this?

Running out of memory?

Possibly yes, but how do I fix this? I don’t want to wait hours for all my
surfaces ti be generated.

How much memory does your computer have? Which operating system?

Rhino for Windows shows the amount of memory it is using, and also the amount of available physical memory. On my screen it shows up in the lower right corner.

Windows has several tools for monitoring memory use, Task Manager in Windows 10 has a Performance Tab and there is also a Resource Monitor available. Other versions of Windows have similar, and third party resource monitors are available.

If you are running out of memory then the two fixes I know of are to add memory if possible, or to reduce the amount of memory the software needs. The amount of memory Rhino needs depends in part on the complexity of the model. First determine if you are running out memory.