Microsoft Knowledge Base Email Alertz

KBAlertz.com: Performance Degradation in Visual Basic 6.0 Components Running in High Throughput Multi-threaded Applications

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 949142 - Last Review: May 11, 2009 - Revision: 2.0

Performance Degradation in Visual Basic 6.0 Components Running in High Throughput Multi-threaded Applications

Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Action

You are running a Visual Basic 6.0 component in a high throughput, multi-threaded application; such as COM+/MTS, Active Server Pages (ASP), or a Visual Basic 6.0 ActiveX EXE.

Result

Performance degrades and/or the application encounters high CPU as the component services a large number of client requests.

Cause

The Visual Basic component may be performing an operation that results in a critical section convoy. Internally Visual Basic 6.0 uses critical sections to protect key data structures, which the Visual Basic run-time uses to maintain a wide range of per-thread project information. If the component is executing code that requires access to the critical section, multiple threads may be waiting to take ownership of the critical section. This causes a delay in each thread servicing its request. Performance may decline over time as more and more threads are created, with each one waiting to access the critical section.

Common scenarios for this to occur would be:

1. Calling procedures or variables stored in standard modules (.bas).
2. Making late bound calls on COM components.
3. Using Visual Basic intrinsic file I/O statements, such as Open, Close, Get, Put, Print, or Write.

Resolution

Consider making the following changes to the Visual Basic component to help avoid critical section convoys in the Visual Basic run-time.

1. Where possible, move procedures and variables stored in standard standard (.bas) modules into class modules.

2. Modify the component to use early bound calls to COM components, rather than late bound calls.

3. If the component is using the Visual Basic intrinsic file I/O statements, use one of the following alternatives instead.
    a. Use the FileSystemObject from the Scripting run-time.
    b. Use the Win32 API ReadFile and WriteFile functions.

    165942 How To Write Data to a File Using WriteFile API
    http://kbalertz.com/165942 (http://support.microsoft.com/default.aspx?scid=kb;en-us;165942)

   c. Reduce the number of times calling the file I/O get and put to read or write data. For example, read and/or write larger chunks of data at a time.


Related Knowledgebase Articles
========================

815053 INFO: Avoid Global Variables in Visual Basic COM+ Components
http://kbalertz.com/815053 (http://support.microsoft.com/default.aspx?scid=kb;en-us;815053)

241896 Threading issues with Visual Basic 6.0 ActiveX components
http://kbalertz.com/241896 (http://support.microsoft.com/default.aspx?scid=kb;en-us;241896)

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

APPLIES TO
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
Keywords: 
kbnomt kbrapidpub KB949142
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please