171 Posts
63 Kudos
Registered: ‎08-26-2010
Post 11 of 12

Re: Processing overkill or API bug?

07-26-2012 08:06 AM in reply to: JamieVJohnson2

Well Byref had no effect as I expected, save one, I used half as much memory from 11gb down to 5gb.  With the file open and doing nothing in AutoCAD I started at 0.7GB, so talk about your bloat.  There is one thing I'd like to investigate.  The debugger keeps poping up this message:


ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x477358 to COM context 0x476d90 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.


I know little to nothing of multi-threaded documents, and weather or not I have any control over such things when working with AutoCAD .Net API.  So this may be a white unicorn chase.



ADN Support Specialist
352 Posts
27 Kudos
Registered: ‎07-24-2007
Post 12 of 12

Re: Processing overkill or API bug?

07-30-2012 04:48 PM in reply to: JamieVJohnson2

First of all, you should read my posts on AutoCAD Performance, it starts off slow but gets to the points you need to read about http://adndevblog.typepad.com/autocad/2012/07/the-right-tools-for-the-job-autocad-part-1.html?cid=6a...


For the code you have listed, you should not mutiply call StartTransaction as it is really inefficient. You should change your code to either pass the currently started Transaction, or change to StartOpenCloseTransaction.


Finally, you should read this post about calling Dispose() http://adndevblog.typepad.com/autocad/2012/07/forcing-the-gc-to-run-on-the-main-thread.html

Fenton Webb

Developer Technical Services

Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post