PRB: Creating Many Fonts Causes a GPF in Windows 3.1

Last reviewed: July 23, 1997
Article ID: Q119454
3.10 WINDOWS kbprg kbprb

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows, version 3.1

SYMPTOMS

When you create or generate TrueType fonts, selectors are lost. Eventually, if you create enough fonts, this problem causes a general protection fault (GPF) in your application.

CAUSE

Under Windows version 3.1, each time a new TrueType font is created, the cache is allocated to hold the TrueType font data. This memory is allocated as discardable memory, so that Windows can discard the font data and give the memory to other applications that need more memory. This way, TrueType font caching does not adversely affect available memory.

The cache memory blocks are not discarded unless forced. Deleting the font handle (HFONT) does not cause the TrueType font cache memory to be deleted. This is a system optimization made in case another application uses the same font.

Each cached TrueType font uses two selectors for its font data. Windows has a system-wide limit of 8192 selectors. When you create many TrueType fonts at once, you can run out of free selectors, which causes Windows to behave unexpectedly; your application may have a general protection fault (GPF). Deleting the font handles when you are finished with the fonts does not prevent this behavior.

In addition, if you allocate a single TrueType font and change the mapping mode frequently, a new physical font is generated for each mapping-mode change. This can also cause the system to run out of free selectors and your application to have a GPF.

RESOLUTION

GlobalAlloc() a large block of memory, create a font, and then delete the font. This forces segments to be discarded, so that the selectors are freed.

The True Type font cache in Windows 95 is designed so that this problem does not occur.


Additional reference words: 3.10
KBCategory: kbprg kbprb
KBSubCategory: GdiFnt
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.