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

Check Description
Ff647714.checkbox(en-us,PandP.10).gif Design chunky interfaces to avoid round trips.
Ff647714.checkbox(en-us,PandP.10).gif Reduce round trips with a facade.
Ff647714.checkbox(en-us,PandP.10).gif Implement IDisposable if you hold unmanaged resources across client calls.
Ff647714.checkbox(en-us,PandP.10).gif Reduce or avoid the use of late binding and reflection.

Marshaling

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

Marshal.ReleaseCOMObject

Check Description
Ff647714.checkbox(en-us,PandP.10).gif Consider calling ReleaseComObject in server applications.
Ff647714.checkbox(en-us,PandP.10).gif Do not force garbage collections with GC.Collect.

Code Access Security (CAS)

Check Description
Ff647714.checkbox(en-us,PandP.10).gif Consider using SuppressUnmanagedCode for performance-critical, trusted scenarios.
Ff647714.checkbox(en-us,PandP.10).gif Consider using TLBIMP /unsafe for performance-critical, trusted scenarios.

Threading

Check Description
Ff647714.checkbox(en-us,PandP.10).gif Reduce or avoid cross-apartment calls.
Ff647714.checkbox(en-us,PandP.10).gif Use ASPCOMPAT when you call single-threaded apartment (STA) objects from ASP.NET.
Ff647714.checkbox(en-us,PandP.10).gif Use MTAThread when you call free-threaded objects.
Ff647714.checkbox(en-us,PandP.10).gif Avoid thread switches by using Neutral apartment COM components.

Monitoring Interop Performance

Check Description
Ff647714.checkbox(en-us,PandP.10).gif Use performance counters for P/Invoke and COM interop.
Ff647714.checkbox(en-us,PandP.10).gif Use 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.

© Microsoft Corporation. All rights reserved.