Memory Consumption Issue

Memory Consumption Issue

darren.braynard2
Contributor Contributor
2,131 Views
12 Replies
Message 1 of 13

Memory Consumption Issue

darren.braynard2
Contributor
Contributor

We are running an automated Revit instance against a model where many views are opened one after another and each time we perform read-only processing of the elements in each view. The problem is that memory continues to grow throughout the processing. Attached is an image of memory/cpu usage for a job that processed 61 views. We have added a call to Application.PurgeReleasedAPIObjects between processing each view, and made a call to View.Dispose() as well. However, memory continues to climb. What other steps can we take to prevent memory growth during processing?

 

The test was with Revit 2015. The plot in the attached image includes 2nd y axis that shows the CPU usage. Memory series are using the 1st y axis.

2,132 Views
12 Replies
Replies (12)
Message 2 of 13

jeremytammik
Autodesk
Autodesk

Yes, well, Revit was designed to be used and driven by a human being through the end user interface. When you drive it programmatically like that, you must expect to hit a limit sometime.

 

Check out these suggestions:

 

 

Good luck and have fun!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 13

darren.braynard2
Contributor
Contributor

I appreciate the response. These are great resources. Though, we are hoping for a technique within the Revit API, since we are not in direct control of the Revit.exe process itself. If we could break up our job into smaller jobs, we could avoid the problem, but it would not be ideal.

 

Thanks,

Darren

0 Likes
Message 4 of 13

jeremytammik
Autodesk
Autodesk

I cannot think of any other feasible approach. Sorry!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 13

FAIR59
Advisor
Advisor

I'm wondering, do you need to open the view to do read-only processing??

0 Likes
Message 6 of 13

darren.braynard2
Contributor
Contributor

I believe so, the elements are processed according to which view(s) have them visible.

0 Likes
Message 7 of 13

jeremytammik
Autodesk
Autodesk

Very good question! You could try NOT to open any views at all... what do you need views for?

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 13

darren.braynard2
Contributor
Contributor

We are using each View object in a call to FilteredElementCollector in order to obtain its visible elements. We are not really "opening" the GUI view.

0 Likes
Message 9 of 13

jeremytammik
Autodesk
Autodesk

Good. Then I am afraid there is little else one can suggest...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 10 of 13

FAIR59
Advisor
Advisor

One final suggestion: where do you store the results of the read-only proces??

0 Likes
Message 11 of 13

darren.braynard2
Contributor
Contributor

We send them out to an external database.

0 Likes
Message 12 of 13

FAIR59
Advisor
Advisor

I see no pure API method to release memory. But by tapping into the UI, there is a possibility .

As an user I can release memory by opening the workset-dialog in a workshared project. This command has a CommandId and hence you can use PostCommand to show the dialog.

Using the dialogshowing event, you can then close the dialog and raise an external event to get control back.

This method isn't "pretty"( the dialog is visible for a split second ), but should work.

 

revit.Application.DialogBoxShowing += Application_DialogBoxShowing;
revit.Application.PostCommand("ID_SETTINGS_PARTITIONS");



void Application_DialogBoxShowing(object sender, Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs e)
        {
            if (!e.DialogId.Equals("Dialog_Revit_Partitions")) return;
            UIApplication uiapp = sender as UIApplication;
            uiapp.DialogBoxShowing -= Application_DialogBoxShowing;
            // raise external event here to get control back
            e.OverrideResult(
               (int)TaskDialogResult.Close);
        }
0 Likes
Message 13 of 13

darren.braynard2
Contributor
Contributor

Thanks @FAIR59. This sounds interesting. I will give it a try and report back my findings.

0 Likes