Microsoft KB Archive/331956

= Tablet PC Object Model Components Leak Resources =

Article ID: 331956

Article Last Modified on 5/21/2007

-

APPLIES TO


 * Microsoft Windows XP Tablet PC Edition
 * Microsoft Windows XP Tablet PC Edition Software Development Kit 1.0
 * Microsoft Windows XP Tablet PC Edition Software Development Kit 1.0
 * Microsoft Windows XP Tablet PC Edition Software Development Kit 1.0

-



This article was previously published under Q331956



SYMPTOMS
When you are using Tablet PC Platform components in a managed-code program, memory usage and the thread count may not be reduced after the garbage collector runs, or after a long time has elapsed.



CAUSE
This problem occurs if a Tablet PC object triggers an event, but that object is not collected later. The hotfix that is described in this article updates the Tablet PC .NET assembly (Microsoft.Ink.dll).



RESOLUTION
To resolve this problem, use of the following links to download and install either the Microsoft Windows XP Tablet PC Edition Software Development Kit (SDK) version 1.5 or the hotfix for versions 1.0 and 1.1 of the SDK.

Tablet PC Platform SDK v1.5
The following file is available for download from the Microsoft Download Center:

Download the Tablet PC Platform SDK v1.5 setup.exe package now.

Service pack information
To resolve this problem, obtain the latest service pack for Microsoft Windows XP. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

322389 How to obtain the latest Windows XP service pack

Hotfix for Versions 1.0 and 1.1 of the SDK
A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next Windows XP service pack or use the Microsoft Windows XP Tablet PC Edition SDK 1.5 release that contains this fix.

To resolve this problem immediately, download the fix by clicking the download link later in this article or contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. The following file is available for download from the Microsoft Download Center:

Download the Q331956_xpt_sp2_x86_enu.exe package now.

Release Date: January 3, 2003

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

  Date         Time   Version     Size     File name --  27-Nov-2002  16:00  1.0.2201.2  379,464  Microsoft.Ink.dll



MORE INFORMATION
To resolve this problem, you must implement the hotfix and add the appropriate code as described in this article.

Installing the Hotfix
To install the hotfix, run the Setup program file that you obtained from Microsoft. The Setup program for this hotfix installs the following files on your computer:
 * Microsoft.Ink.dll
 * MstpcQ331956.msm
 * ReadMe.htm
 * License.txt
 * Redist.txt

By default, these files are installed in the %CommonProgramFiles%\Microsoft Shared\Ink\1.2 folder, where %CommonProgramFiles% is the environment variable that contains the location of your common program files folder.

The Setup program registers the updated Microsoft.Ink.dll assembly in the Global Assembly Cache. In Windows XP and Microsoft Windows 2000, this works only if the Microsoft .NET Framework is installed. This occurs automatically in Tablet PC Edition.

Updating Your Assembly Reference
Follow these steps to use the updated file in your program:  Open your program in Microsoft Visual Studio .NET. Remove the reference in your program to the original Tablet PC .NET assembly (Microsoft.Ink.dll) with this strong name:

&quot;Microsoft.Ink, Version=1.0.2201.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null&quot;

 Add a reference in your program to the updated version of the Tablet PC .NET assembly (Microsoft.Ink.dll) by using this strong name:

&quot;Microsoft.Ink, Version=1.0.2201.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null&quot;

 Recompile your program by using the updated Microsoft.Ink.dll file.

Verifying Your Assembly Reference
After you have updated the assembly reference, verify that your program correctly references the new assembly. Recompile your program and then open it by using the Microsoft Intermediate Language Disassembler tool (ILDASM). This tool is included with Visual Studio .NET and is located in the %ProgramFiles%\Microsoft Visual Studio .NET\FrameworkSDK\Bin folder, where %ProgramFiles% is the environment variable that contains the path to the Program Files folder on your computer.

Use the tool to verify in the Manifest section that the file version of the Microsoft.Ink.dll file matches the updated version number, which is 1.0.2201.2.

Making Changes to Your Program
This update to the Tablet PC Platform assembly may affect how your program uses the following members of the Tablet PC Platform object model:
 * InkCollector
 * InkPicture
 * InkOverlay
 * Strokes
 * Ink
 * RecognizerContext

These objects are affected only if you synchronize events on these objects. If you do not synchronize events on these objects, you do not have to modify your code.

If your code listens for events on these objects, there are two changes that you must make in your managed-code program after you reference the new assembly. These changes are calling Dispose in client programs, and derived class event changes.

Calling Dispose in Client Programs
After you have updated the reference to the Tablet PC SDK .NET assembly, you must modify your program to call the Dispose method on all objects that use events when you are finished using them. If you do not call Dispose on objects that trigger events, that object will leak.

Note The object leaks last only until your program is quit. During the shutdown process, the garbage collector releases all the objects, including those that trigger events. Any necessary finalizers on the objects are called.

Derived Class Event Changes
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, see the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For additional information about the support options available from Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

If your program derives from InkCollector, InkPicture, or InkOverlay, no events are triggered unless you create a delegate. For example: myInkCollector.Stroke += new InkCollectorStrokeEventHandler(MyStrokeEventHandler); If your program derives from any one of these three classes and has client code that synchronizes events on object instances, your derived class must implement the IDisposable interface. You must also create a private &quot;dummy&quot; event handler for any event that you want to receive (every overridden event call) whether or not your client listens for these events. The following code provide an example how to do this for an event: private InkCollectorStrokeEventHandler onStroke; ...

public event InkCollectorStrokeEventHandler Stroke {   // Add a new event handler to the Stroke event source. add {       onStroke += value; // If this is the first time that the event is being listened to, // sink the underlying object's event. if (value != null &&            onStroke.GetInvocationList.GetLength(0) == value.GetInvocationList.GetLength(0)) {           base.Stroke += new InkCollectorStrokeEventHandler(dummyEventHandler); }   }    // Remove an existing event handler from the Stroke event source. remove {       if (onStroke != null) {           onStroke -= value;

// If a listener was removed and there are no more listeners, // remove the underlying event listener. if (null == onStroke && !disposed) {               base.Stroke -= new InkCollectorStrokeEventHandler(dummyEventHandler); }       }    } } In the Dispose implementation, remove any delegates that you added: Dispose(...) ...   if (onStroke != null) {       base.Stroke -= new StrokeEventHandler(dummyEventHandler); } ... Finally, as with the base objects, clients should call Dispose on the derived objects when they are finished using them.

Distributing Your Program
After you have modified and tested your program, you can redistribute the updated assembly with your program by using the provided redistributable merge module (MstpcQ331956.msm). This merge module installs the updated assembly and registers it in the Global Assembly Cache on the computer on which it is installed. Your program can then use the updated assembly.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section. This problem was first corrected in Microsoft Windows XP Service Pack 2.

Keywords: kbbug kbfix kbqfe kbwinxpsp2fix kbwinxppresp2fix atdownload kbhotfixserver KB331956

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.