Why is SOLIDWORKS Crashing? [VIDEO]

Article by Adam Bridgman, CSWE updated February 3, 2014

Article

What I am showing is not technically a crash, but to users of SOLIDWORKS the result is the same.

GDI objects are used to draw window elements that are not in the graphics area in SolidWorks.  For maximum performance the Graphics area takes advantage of OpenGL which gives more direct access to the video processing hardware.  GDI objects are used for the chrome of the graphics area, so every time a new document is opened the number of GDI objects used by SOLIDWORKS will increase.  Prior so SOLIDWORKS 2011 SP4 if a part was open in an assembly and its own window when that window was closed it would not release those GDI objects.  The default behaviour now is to release those handles, however not all of them are released.

What does all this have to do with SOLIDWORKS crashing? Windows has a default limit that a single process can only access 10,000 GDI objects.  Since SolidWorks does not release all objects when a document is closed that number it uses continuously increases with each new document opened.

Can this be used to predict when SOLIDWORKS will crash?

Predicting a SOLIDWORKS Crash

As mentioned earlier this is not technically a crash, if SOLIDWORKS reaches the 10,000 object limit windows terminates the process.  This is not caused by unhandled code error or memory sharing issues or anything else that causes a crash.  This is simply windows saying SOLIDWORKS is being too much of a resource hog and closes it to get those resources back.  But since there is a specific number at which it closes if you can monitor that number you can predict when it will happen.  As it turns out it is actually very easy to monitor.  Simply follow these steps:

  1. Open task manager (you can right click on the task bar and click task manager)
  2. Click View, Select Columns…
SOLIDWORKS Crashing

Select Columns in Windows Task Manager

  1. Check off GDI Objects and click OK
Display GDI Objects

Display GDI Objects

  1.  Now  the task manager will show the current number of GDI Objects being used by each process
GDI Objects Displayed

GDI Objects Displayed

If a part is opened and closed several times the number of GDI objects it uses does not increase. SOLIDWORKS releases all handles every time.  The same applies to assemblies as well.  The problem is only encountered when a part is open in an assembly and it is opened in its own window and then closed.  Here is a table of a session I recorded on my computer:

Description

User Objects

GDI Objects

No docs open

1191

939

Part open

1308

1297

Assembly made

1397

1464

Part open 1

1397

1483

Part closed 1

1284

1346

Part open 2

1395

1498

Part closed 2

1283

1363

Part open 3

1396

1525

Part closed 3

1283

1390

Part open 4

1396

1549

Part closed 4

1283

1413

Part open 5

1396

1572

Part closed 5

1284

1437

Part open 6

1396

1627

Part closed 6

1284

1492

Part open 7

1397

1652

Part closed 7

1284

1516

Assembly closed

1179

1366

Assembly made

1402

1674

Part activated

1401

1695

Part closed

1288

1555

Assembly closed

1181

1401

When I originally opened SOLIDWORKS it used 939 objects with no documents open.  After opening and closing a part several times with an assembly open and then closing all documents it still used 1401 objects.  Over a long period of time this could reach the 10,000 mark, especially if you open the top level assembly.

Avoiding this crash problem

How can this problem be avoided? Do not keep your assemblies open unless you need them to be, and monitor your task manager periodically to see how many objects you are using.  Closing SOLIDWORKS and opening it will reset this count.  Furthermore you can increase the maximum number of GDI Objects a process can use by following these settings:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\GDIProcessHandleQuota (range: 256 ~ 65,536)
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERProcessHandleQuota (range: 200 ~ 18,000)

For additional information, please visit the following websites for a description on how these settings affect a computer:

Video Overview

Related Links

Get Certified SOLIDWORKS Services from Javelin

Javelin Experts can help you to:

Adam Bridgman, CSWE

Adam Bridgman in SOLIDWORKS Certified Expert proving customers with technical support and training