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
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
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