# High usage memory when using and integrating dynamo and pyrevit

**URL:** <https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [June 23, 2024, 10:47am UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128 "2024-06-23T10:47:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![najwan.joan.sv](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@najwan.joan.sv](https://forum.dynamobim.com/u/najwan.joan.sv)\
**Post date:** [June 23, 2024, 10:47am UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/1 "2024-06-23T10:47:31Z")

</div>

Hello everyone,

So basically i’ve made a program using dynamo that can be run through the revit ribbon tab. Im using [pyrevit](https://discourse.pyrevitlabs.io/) to make that happen. but eventually its taking the Memory RAM too much and greyed out the revit application, even i have already upgraded my laptop to 32 gigs memory.

But not just that, im still getting the greyed screen (Not Responding) when im run through dynamo itself

Im using ROG Strix g153qc,  
AMD Ryzen 7 5800H  
RTX 3050 Laptop  
Still have plenty room for storage (20± GB) on C: Drive

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/c/fc926d52287f808fb48e6eb6cdd6de2ad27121c5.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/2/723c68d989de77f87ad0dd0fb41546768ff82729.png)

[UniversalRailing\_script.dyn](https://forum.dynamobim.com/uploads/short-url/c4pA4DY1w4rtwIbEYSBQQPkULB7.dyn) (357.0 KB)  
This the example of one my feature. it takes too long and not responding on my devices. is there any optimized version to my feature?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 23, 2024, 12:11pm UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/2 "2024-06-23T12:11:25Z")

</div>

> [@najwan.joan.sv](#):
>
> it takes too long and not responding on my devices

Can you define ‘too long’? Is it too long as in ‘it takes 20 seconds to process the entire model’, or is it ‘it takes 2 hours to process one view’?

---

<div class="post-metadata">

**Author:** ![najwan.joan.sv](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@najwan.joan.sv](https://forum.dynamobim.com/u/najwan.joan.sv)\
**Post date:** [June 23, 2024, 1:27pm UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/3 "2024-06-23T13:27:06Z")

</div>

its too long to run the dynamo. when i run it takes 5-10 minutes to show the DataShapes GUI. after i input all the form, then click run, it takes 20-30 minutes even the revit force closed.

all the waiting times the revit and dynamo application is grayed out and says not responding.

the dynamo files that i made itself generally basically placing an family based on lines or point through dynamo… it can be 200+ lines or points, depends on whats the input

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 23, 2024, 2:20pm UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/4 "2024-06-23T14:20:36Z")

</div>

Double check to ensure there are not element bindings, as slow to trigger the UI indicates that is at least part of the issue.

> [@Element Binding in Revit](https://forum.dynamobim.com/t/element-binding-in-revit/31612):
>
> Element binding is the name given to the process which Dynamo manage to ‘track’ the items created in non-Dynamo files. In this case, I’m going to focus entirely on element binding as it refers to Dynamo for Revit, but the mechanism exists to allow for this behavior in other applications (advanced steel, fusion, alias, etc.) as well. In the context of Revit, ‘elements’ refers to anything with an Element ID in the Revit database. When utilized correctly, element binding will expand how you leverag…

---

<div class="post-metadata">

**Author:** ![najwan.joan.sv](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@najwan.joan.sv](https://forum.dynamobim.com/u/najwan.joan.sv)\
**Post date:** [June 24, 2024, 12:46am UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/5 "2024-06-24T00:46:01Z")

</div>

I Have already check all my dynamo .dyn file through visual studio code.

Totally i have 12 .dyn file

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/6/b6c53039bb1325a28a71745b15bbbdf318ebd82e.png)

This is one of the .dyn file i have, as you can see.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/4/4464707543176e082c19d1503acb4ad2f6cbcead.png)

All the file HAS NOT Bindings EXCEPT the underlined file. Like your example below.

> [@Element Binding in Revit](https://forum.dynamobim.com/t/element-binding-in-revit/31612/1):
>
> ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/5948e6ea5e1362b42c6876c99e74da6101df7dfe.png)
> 
> image957×839 65.3 KB

I have already turn off the preview element on all nodes, i was thinking so because maybe it taking the GPU or RAM to render. So i turned it off.

Hmm wondering whats caused the issue.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 24, 2024, 6:05am UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/6 "2024-06-24T06:05:13Z")

</div>

Well, clear the bindings on that file.

---

<div class="post-metadata">

**Author:** ![najwan.joan.sv](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@najwan.joan.sv](https://forum.dynamobim.com/u/najwan.joan.sv)\
**Post date:** [June 24, 2024, 6:17am UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/7 "2024-06-24T06:17:05Z")

</div>

Yes, but i mean, the file with or without bindings. still getting high usage ram, still getting that grayed out not responding applications.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 24, 2024, 7:29am UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/8 "2024-06-24T07:29:14Z")

</div>

It likely means your code is either doing to much (process all the content in all the files all at once and keep them in memory to boot), isn’t using efficient architecture (multiple all elements of category, not filtering early and fast), failing to handle errors (nulls are slower to process), is doing more than is needed (boolean intersection tests for 100 solids for each object instead of a unioning thr 100 solids), or using poor code (instead of a modulo function, using an if statements to find out if a number is even or odd).

I cannot diagnose all of them for you. Start by stripping out the UI and see if that speeds it along. Continue to reduce scope (even if it means you get incomplete results) until you identify the slow bit. Once you know the slow bit, look for alternative ways to get what you are after - change Python to C#; reduce scope by pre filtering, etc…

---

<div class="post-metadata">

**Author:** ![najwan.joan.sv](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@najwan.joan.sv](https://forum.dynamobim.com/u/najwan.joan.sv)\
**Post date:** [June 24, 2024, 3:21pm UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/9 "2024-06-24T15:21:54Z")

</div>

Ouhh okay, so i need to optimize the flow…

> [@jacob.small](#):
>
> change Python to C#;

hmm unfortunately ive never been use python or C# to code using RevitAPI, im using python is to process numbers, if else, string operation and database…

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 24, 2024, 3:30pm UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/10 "2024-06-24T15:30:23Z")

</div>

Step 1 is diagnosing the slow portion; don’t both looking into how to fix all the code as you’ll tackle the wrong area first. Find what is slow and work from there. For learning C# or Python for Dynamo development there are a lot of great existing topics on the forum - best to start there once you know ‘where’ the slowdown is.

Also, be sure you aren’t loading any resources from an external location or working in a cloud mirrored environment (ie if onedrive is mirroring your entire user folder you’re going to be slowed down exponentially)

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [June 24, 2024, 3:35pm UTC](https://forum.dynamobim.com/t/high-usage-memory-when-using-and-integrating-dynamo-and-pyrevit/102128/11 "2024-06-24T15:35:14Z")

</div>

Hey,

Did you post on the [PyRevit](https://discourse.pyrevitlabs.io/) forum? There might be something about the Py setup which is the problem… You can also post on their Github Issues?

Hope that helps,

Mark
