Error -12: Out of Memory When Creating User Interface in LabWindows™/CVI™

Updated Apr 30, 2018

Reported In


  • LabWindows/CVI


  • Windows 7

Issue Details

I am programmatically creating an extensive User Interface (UI) in LabWindows™/CVI™ using the CopyTabPage (panel, TAB, 0, panel, TAB, -1) function. When the UI becomes very complex, I receive Error -12: Out of Memory. How do I resolve this problem?


The Error -12: Out of Memory error occurs because Windows 7 exceeded the maximum number of GDI Handles. This can happen when your UI has too many GDI Objects (Bitmaps, Brushes, Fonts, etc.) opened which are identified in OS by GDI Handles. There is per-process limit of 10,000 GDI Handles defined by default. 

To check how many GDI Objects you have in particular process, go to Windows Task Manager»Processes»View»Select Columns and check GDI Objects. Then you will be able to see the number of GDI Objects for particular process in the GDI Objects column. If the number of GDI Objects is close to 10,000, you will not be able to create other graphical items without receiving Error -12: Out of Memory

There are two ways to resolve this issue:
1. Redesign your application to reduce the number of GDI resources.
2. Increase the GDI Handles limit via registry value up to 65,536 (64k). 

Additional Information

  • WARNING: Inappropriate changes to the Windows Registry can damage your operating system! To safeguard against such an event, you should backup your existing Registry by choosing File»Export after launching the Registry Editor and before making any changes.

    The registry key which governs the limit of GDI Handles is 


  • Be aware that:
    • You are changing registry, so take into account all risks related to this operation.
    • Raising this limit does not raise the available kernel memory to store the actual GDI objects that the handles identify.
    • Raising this limit reduces the number of GDI objects that the rest of the system, including Windows itself, can use.
Note: NI does not recommend editing the registry as a solution.