High Memory and CPU Usage When Debugging Lots of Dynamic Types
Source: Microsoft Support RAPID PUBLISHINGRAPID 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. ActionDebugging managed code that contains a lot of dynamically created types. ResultHigh memory usage accompanied by high cpu usage. CauseHigh Memory Usage: The Visual Studio debugger makes a copy of meta-data every time a managed dynamic type is created, even when it already has a previous copy of the same type cached. This is because there may still be outstanding references to the old copy. So, when re-creating dynamic types, not only does the debugger make a copy of meta-data for itself to use, it may also create what amouts to a duplicate copy. High CPU: This particular pattern of memory usage can also lead to fragmented native heaps in the process. As the debugging activity progresses, native heaps can become more and more fragmented, causing high cpu usage as it becomes more and more difficult to free continguous space. ResolutionMore InformationThe only known workaround is to detach the debugger periodically and re-attach. When the debugger is detached, the copies of metadata are freed. Othewise, be sure you are caching dynamic types such that you don't re-create them, resulting in multiple copies of metadata for the same type. Also, try to limit the number of dynamic types used; try to consolidate functionality in as few dynamic types as reasonably possible. DISCLAIMERMICROSOFT 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
|
|
Back to the top
