How to free memory(RAM) after a script is done?

Hi, everyone!

I found that this is not happening with closing Dynamo, or even closing Revit project. Only closing Revit program releasing the memory.
Is there a way to do so without closing Revit and Revit project?

Kind regards,
Dmitry Semko.

Please explain how the script has been done because if this is done via python you can utilize “dispose” which is part of the revit api to free up the memory.

1 Like

As Brendan suggest, if you are generating geometry via python/c#, it is a good practice to dispose them if they are not meant to be rendered/tessellated.

See links below, hope it helps:
https://github.com/DynamoDS/Dynamo/wiki/Efficiently-Working-With-Large-Data-Sets-In-Dynamo
https://github.com/DynamoDS/Dynamo/wiki/Zero-Touch-Plugin-Development#dispose–using-statement

1 Like

Sometimes it is a python script, but basically, it’s an OOTB nodes. So, the only possibility is to use python\C# and “dispose” method from API and we can do nothing if it’s OOTB nodes?

According to the first link:

Geometry nodes in Dynamo are always tessellated*. This leaves you with two options to work with untessellated geometry: Python nodes and ZeroTouch nodes.

and

…let’s say you were creating hundreds of thousands of NurbsCurves, each requiring dozens of Points. One way to create them is a 2 dimensional list in Dynamo, and feed that into a NurbsCurve.ByPoints node. However, that requires creating millions of Points. Another way is to use a Python or ZeroTouch node. In this node, you can create a dozen points, feed that into NurbsCurve.ByPoints, and then dispose of the dozen points with the .Dispose() method call.

There is not confirmation about the geometry being tessellated if preview is disable, but still if you are generating tons of intermediate geometry to get your final result,I would recommend to encapsulate the logic in a python/c# node and handle that geometry yourself. This way you have more control in the overall performance of your code.:slight_smile:

1 Like

Does Zero Touch work with objects that are not geometry?

I am running large scripts which are just moving data around. Works fine for running the scripts, but after I am finished and run a different add-in in revit, things crawl.

An update…

I am using Dynamo Player to execute my scripts, which is another area where I notice performance issues.
It seems like running a “blank” script will free up the memory.

My blank script performs a simple addition function, but I suppose it could be completely blank?

My guess is that Dynamo somehow maintains an allocation of the ram, and uses it to reduce run times for scripts which are run multiple times during development. Once a new script is run, I assume the ram is released.

Does anyone know?

I use Cleanmem http://www.pcwintech.com/cleanmem
image

1 Like

Hi truevis,

I saw the CleanMem pop up somewhere while looking for answers.

The blank script seems to work now. Just curious how it works.

Is there any other advantage / reason to use clean mem aside from releasing the dynamo memory?

Cheers,
Matt

It seems to free memory that gets used up by just using regular Revit.