Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GBSXML Export Runtime

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
316 Views, 3 Replies

GBSXML Export Runtime

Hello,

 

I have been working with a plugin that implements the Autodesk.Revit.DB.Document function to export a Revit document and its accompanying MassGBXMLExport options to a xml as input for Green Building Studio. 

 

Our plugin will sometimes call this function up to a hundred times on execution on different Revit models. I have observed that the runtime of the function grows by a factor of N (more-or-less) every time it is called. I could be wrong but I think the underlying Revit function that the API is calling might be leaking memory. Is there any fix to this issue and has it been obeserved in the past?

 

Thanks!

 

-Boian

3 REPLIES 3
Message 2 of 4
arnostlobel
in reply to: Anonymous

Hello Boian:

I assume you mean the Document. Export (String, String, MassGBXMLExportOptions) method you were referring in your post.

I kind of doubt it leaks memory, but everything is possible, naturally. However, what seems more likely to me is that the garbage collector is not releasing its collected garbage often enough, and Revit itself forces garbage collection only at the ends of external commands (and events, etc.) - basically only when the processing comes to Revit from back from an external application.

An application that is likely to use a large amount of memory (like printing and exporting the entire model) can make use of the Application.PurgeReleaseAPIObjects method, which will force garbage collection, which in turn may also release some native memory if it has been held by managed objects. I suggest you give it a try and see if it helps.

Thank you
Arnošt Löbel
Message 3 of 4
Anonymous
in reply to: arnostlobel

Hello Arnost,

 

Is Application.PurgeReleaseAPIObjects forcing C# garbage collection? I have been trying to force garbage collection with Application.PurgeReleaseAPIObjects and GC.Collect() but I am observing the same behavior. Is Document. Export (String, String, MassGBXMLExportOptions) calling a native C++ function through the revit API? Is it possible to perform C++ garbage collection through C#? 

 

Thanks!

 

-Boian

Message 4 of 4
arnostlobel
in reply to: Anonymous

Boian,

 

Virtually all methods and properties in the Revit API call into a native method in Revit. The API is mostly just a thin shell around Revit DB core functions (which is otherwise normally invoked from Revit UI)..

 

As for the PurgeReleaseAPIObjects method, it indeed does more than just invoking GC.Collect and that “more” is exactly the point of this method. It invokes GC.Collect, waits for it, and then purges native memory that might have been held up by the just released managed objects. You may indeed call this second part a C++ garbage collection, in a way, although it is totally a custom solution, for there is no garbage collecting in native C++.

 

Thank you

Arnošt Löbel

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community