Checklist: Interop Performance

 

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

patterns & practices Developer Center

Improving .NET Application Performance and Scalability

J.D. Meier, Srinath Vasireddy, Ashish Babbar, and Alex Mackman
Microsoft Corporation

May 2004

Related Links

Home Page for Improving .NET Application Performance and Scalability

Send feedback to Scale@microsoft.com

patterns & practices Library

How to Use This Checklist

This checklist is a companion to Chapter 7, "Improving Interop Performance"

Design Considerations

CheckDescription
Ff647714.checkbox(en-us,PandP.10).gifDesign chunky interfaces to avoid round trips.
Ff647714.checkbox(en-us,PandP.10).gifReduce round trips with a facade.
Ff647714.checkbox(en-us,PandP.10).gifImplement IDisposable if you hold unmanaged resources across client calls.
Ff647714.checkbox(en-us,PandP.10).gifReduce or avoid the use of late binding and reflection.

Marshaling

CheckDescription
Ff647714.checkbox(en-us,PandP.10).gifExplicitly name the target method you call.
Ff647714.checkbox(en-us,PandP.10).gifUse blittable types where possible.
Ff647714.checkbox(en-us,PandP.10).gifAvoid Unicode to ANSI conversions where possible.
Ff647714.checkbox(en-us,PandP.10).gifUse IntPtr for manual marshaling.
Ff647714.checkbox(en-us,PandP.10).gifUse [in] and [out] to avoid unnecessary marshaling.
Ff647714.checkbox(en-us,PandP.10).gifAvoid aggressive pinning of short-lived objects.

Marshal.ReleaseCOMObject

CheckDescription
Ff647714.checkbox(en-us,PandP.10).gifConsider calling ReleaseComObject in server applications.
Ff647714.checkbox(en-us,PandP.10).gifDo not force garbage collections with GC.Collect.

Code Access Security (CAS)

CheckDescription
Ff647714.checkbox(en-us,PandP.10).gifConsider using SuppressUnmanagedCode for performance-critical, trusted scenarios.
Ff647714.checkbox(en-us,PandP.10).gifConsider using TLBIMP /unsafe for performance-critical, trusted scenarios.

Threading

CheckDescription
Ff647714.checkbox(en-us,PandP.10).gifReduce or avoid cross-apartment calls.
Ff647714.checkbox(en-us,PandP.10).gifUse ASPCOMPAT when you call single-threaded apartment (STA) objects from ASP.NET.
Ff647714.checkbox(en-us,PandP.10).gifUse MTAThread when you call free-threaded objects.
Ff647714.checkbox(en-us,PandP.10).gifAvoid thread switches by using Neutral apartment COM components.

Monitoring Interop Performance

CheckDescription
Ff647714.checkbox(en-us,PandP.10).gifUse performance counters for P/Invoke and COM interop.
Ff647714.checkbox(en-us,PandP.10).gifUse CLR Spy to identify interop problems.

patterns & practices Developer Center

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Show: