added SSCLI 1.0
[windows-sources.git] / sdk / samples / FrameworkSamples / CLR / GCDemo / readme.htm
blob9258767dde6bb03724bb21e9568c8793beb840e7
1 <html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" /><META NAME="save" CONTENT="history" /><title xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">Adding and Removing Memory Pressure Application Sample</title><META NAME="Description" CONTENT="&#xD;&#xA; This sample demonstrates the interoperation of managed garbage collection with unmanaged code.&#xD;&#xA; "></META><META NAME="MS.LOCALE" CONTENT="en-us" /><style>
2 body
3 {font-family:Verdana;font-size:medium;}
4 div#mainSection, div#header
5 {font-size:70%;width: 100%;}
6 div#mainBody
7 {font-size:90%;}
8 div#mainSection div table
9 {font-size: 100%;text-align: left;}
10 span#nsrTitle
11 {color:#003399;font-size:90%;font-weight:600;}
12 div#header
13 {background-color:#D4DFFF;}
14 .heading
15 {font-size:120%;color:#003399;}
16 .subHeading
17 {font-size:100%;margin-bottom:4;}
19 {margin-top:-2;margin-bottom:3;}
21 {margin-top:10;margin-bottom:5;}
22 div.tableSection p
23 {margin-top:1;margin-bottom:4;}
24 div#mainSection table th
25 {background-color:#EFEFF7;color:#000066;text-align:left;}
26 div#mainSection table td
27 {background-color:#F7F7FF;}
28 div#mainSection table
29 {margin-top:5px;margin-bottom: px;}
30 </style></head><body><div id="header"><table width="100%" id="topTable"></table></div><div id="mainSection"><div id="mainBody"><br /><font color="DarkGray">[This readme is a partial copy of the sample's topic in the SDK documentation.]</font><br /><font color="DarkGray" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"></font><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"></p><div class="introduction"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
31 This sample demonstrates the interoperation of managed garbage collection with unmanaged code.
32 </p><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
33 For information about using the samples, see the following topics:
34 </p><ul xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p><span sdata="link">How to: View and Download Samples</span></p></li><li><p><span sdata="link">How to: Set Sample Settings</span></p></li></ul></div><h3 class="procedureSubHeading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">To build the sample using the Command Prompt</h3><div class="subSection"><ol xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p>
35 Open the Command Prompt window and navigate to one of the language-specific subdirectories under the GCDemo directory. For information about required settings and the SDK Command Prompt, see <span sdata="link">How to: Set Sample Settings</span>.
36 </p></li><li><p>
37 Type <span class="input">msbuild GCDemoCS.sln</span> or <span class="input">msbuild GCDemoVB.sln</span> at the command line, depending on your choice of programming language.
38 </p></li></ol></div><h3 class="procedureSubHeading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">To build the sample using Visual Studio</h3><div class="subSection"><ol xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p>
39 Open Windows Explorer and navigate to one of the language-specific subdirectories under the GCDemo directory.
40 </p></li><li><p>
41 Double-click the GCDemoCS.sln or GCDemoVB.sln file, depending on your choice of programming language, to open the file in Visual Studio.
42 </p></li><li><p>
43 In the <span class="ui">Build</span> menu, select <span class="ui">Build Solution</span>.
44 </p></li></ol></div><h3 class="procedureSubHeading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">To run the sample</h3><div class="subSection"><ul xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><li><p>
45 Open the Command Prompt window and navigate to the directory that contains the new executable.
46 </p></li></ul></div><h1 class="heading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><span onclick="ExpandCollapse(requirementsTitleToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(requirementsTitleToggle, event)" tabindex="0">Requirements</span></h1><div id="requirementsTitleSection" class="section"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
47 These samples require Windows headers which are available to your project if you build using Microsoft Visual Studio 2005, the <span class="ui">Visual Studio 2005 Command Prompt</span>, or if you have the Platform SDK installed and specified in an include path.
48 </p></div><h1 class="heading" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><span onclick="ExpandCollapse(sectionToggle0)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(sectionToggle0, event)" tabindex="0">Remarks</span></h1><div id="sectionSection0" class="section"><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
49 This sample demonstrates the new <span sdata="cer" target="M:System.GC.AddMemoryPressure(System.Int64)">AddMemoryPressure</span> and <span sdata="cer" target="M:System.GC.RemoveMemoryPressure(System.Int64)">RemoveMemoryPressure</span> methods of the <span sdata="cer" target="T:System.GC">GC</span> class. You can use these methods to change the pattern of the garbage collection strategy for generation-zero collections. You should use them to give the garbage collector (GC) a hint, whenever the number of unmanaged resources being allocated is significantly higher than the managed footprint for the same resources. Without this hint, the GC is unaware of the unmanaged memory, and can therefore select a suboptimal collection strategy.
50 </p><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
51 Simply run the sample, and observe the number of successful allocations with and without the memory pressure (you will notice that the allocations are more successful when you add pressure appropriately). Also, observe the effect the added pressure has on the number of generation-zero collections performed, indicating the fact that the GC is performing several more collections when pressure is added.
52 </p><p xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
53 Always remember to pair any added pressure with an appropriate removal of the same amount of pressure.
54 </p></div></div></div></body></html>