Autodesk.Revit.DB.CustomExporter.Export(IList`1 viewIds) can run out of RAM

Autodesk.Revit.DB.CustomExporter.Export(IList`1 viewIds) can run out of RAM

MattKincaid
Advocate Advocate
930 Views
5 Replies
Message 1 of 6

Autodesk.Revit.DB.CustomExporter.Export(IList`1 viewIds) can run out of RAM

MattKincaid
Advocate
Advocate

Sometimes, we'll see exceptions like these from our customers.  Haven't been able to get a model to reproduce with, but will attach to this thread if we do.  I'd imagine it occurs when running a customExporter on a  geometrically complex 3d View. 

 

Is it possible to check whether sufficient memory is available, before invoking the Export() call? 

 

Exception:
Autodesk.Revit.Exceptions.ExternalApplicationException: Exception of type 'System.OutOfMemoryException' was thrown.
at Autodesk.Revit.DB.CustomExporter.Export(IList`1 viewIds)

0 Likes
931 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor

I doubt such a thing can be predicted because windows manages memory through a combination of RAM and Virtual memory allocation i.e. if a continuous block can be allocated.

 

Probably easier to catch the exception and provide your own message to that.

0 Likes
Message 3 of 6

MattKincaid
Advocate
Advocate

Thanks for the response!

 

--- > Probably easier to catch the exception and provide your own message to that.

 

Certainly easier to do that than fix a memory leak in Revit : ).  The challenge is what to make the message say that is helpful to the user?  We could direct them to simplify their model, but many users don't like that suggestion, in my experience.  The model just is what it is, and they want the Addin to work, w/o having to modify the model.

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor

I think of messaging in terms of being transparent about what you as a developer can't control, so referring to recommended minimum specification to run Revit.

 

Probably it needs to be investigated if the model size is reasonable and system is meeting the recommendations to run Revit. If they can print/export such views in Revit without an issue with a system of that minimum specification you would think you should be able to export them via API and it is then for Autodesk to investigate the API side? So that is a question to ask them perhaps (if they have similar issues exporting views another way)?

 

If you had a second option to export one view at a time in a loop I'm not sure that would help since the API seems to hold on to resources until the end of the external command. Also worth getting them to test though if that alternative can be implemented as a test.

0 Likes
Message 5 of 6

jeremy_tammik
Alumni
Alumni

Interesting suggestion:

 

> run it in a loop view by view but the API seems to hold on to resources until the end of the external command.

 

One way to work around that might possibly be to launch each loop iteration as a separate external command, and trigger the execution of the next loop iteration as a new external command using PostCommand.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 6

MattKincaid
Advocate
Advocate

@RPTHOMAS108Thanks for the looping suggestion.  May give that a shot.  Though, it would be handy if Revit handled that internally.  Thanks also for the UI tips!  Referencing the minimum specs is a good idea, that I hadn't thought of.  We've heard about this error on a number of different computers, but I'm not sure whether they met the minimum specs or not. 

 

In case it's helpful for investigation purposes, this particular exception was generated by passing a list containing a single view id.  So looping wouldn't help in that situation, but may be a good defensive strategy anyway.  My guess is it's just a beast of a view.

 

We also sometimes see a similar exception with this API.  Perhaps related?

Autodesk.Revit.Exceptions.ExternalApplicationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Autodesk.Revit.DB.CustomExporter.Export(IList`1 viewIds)

 

API version 22.0.2.392 (occurs in earlier versions, too).

0 Likes