<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FWindows%2FMemory</id>
		<title>Csharp/CSharp Tutorial/Windows/Memory - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FWindows%2FMemory"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Windows/Memory&amp;action=history"/>
		<updated>2026-04-29T18:55:53Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Windows/Memory&amp;diff=6716&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Windows/Memory&amp;diff=6716&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Windows/Memory&amp;diff=6717&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Windows/Memory&amp;diff=6717&amp;oldid=prev"/>
				<updated>2010-05-26T12:20:18Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Allocate and free memory==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    UsePointers();&lt;br /&gt;
  }&lt;br /&gt;
  static unsafe public void UsePointers()&lt;br /&gt;
  {&lt;br /&gt;
    char * pMyArray = (char*)Marshal.AllocCoTaskMem(6);&lt;br /&gt;
    while (*pMyArray != &amp;quot;\0&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(*pMyArray);&lt;br /&gt;
      pMyArray++;&lt;br /&gt;
    }&lt;br /&gt;
    Marshal.FreeCoTaskMem((IntPtr)pMyArray);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Allocate memory with System.Runtime.MemoryFailPoint==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        using (System.Runtime.MemoryFailPoint gate = new System.Runtime.MemoryFailPoint(100))&lt;br /&gt;
        {&lt;br /&gt;
            // Some operation that actually uses the 100MB of memory�&lt;br /&gt;
            Console.WriteLine(&amp;quot;Success for 100MB fail-point&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        using (System.Runtime.MemoryFailPoint gate = new System.Runtime.MemoryFailPoint(1024*100))&lt;br /&gt;
        {&lt;br /&gt;
            // Some operation that actually uses the 100GB of memory�&lt;br /&gt;
            Console.WriteLine(&amp;quot;Success for 100GB fail-point&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create Heap and destroy Heap==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
public sealed class MainClass&lt;br /&gt;
{&lt;br /&gt;
    [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
    static extern IntPtr HeapCreate(uint flOptions, UIntPtr dwInitialSize,UIntPtr dwMaximumSize);&lt;br /&gt;
    [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
    static extern bool HeapDestroy(IntPtr hHeap);&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        IntPtr theHeap = HeapCreate( 0, (UIntPtr) 4096, UIntPtr.Zero );&lt;br /&gt;
        HeapDestroy( theHeap );&lt;br /&gt;
        theHeap = IntPtr.Zero;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Demonstrate stackalloc==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  unsafe public static void Main() { &lt;br /&gt;
    int* ptrs = stackalloc int[3]; &lt;br /&gt;
 &lt;br /&gt;
    ptrs[0] = 1; &lt;br /&gt;
    ptrs[1] = 2; &lt;br /&gt;
    ptrs[2] = 3; &lt;br /&gt;
 &lt;br /&gt;
    for(int i=0; i &amp;lt; 3; i++) &lt;br /&gt;
      Console.WriteLine(ptrs[i]); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;1&lt;br /&gt;
2&lt;br /&gt;
3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Free Memory==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime.ConstrainedExecution;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using Microsoft.Win32.SafeHandles;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        IntPtr ptr = Marshal.AllocHGlobal(1024);&lt;br /&gt;
        GC.AddMemoryPressure(1024);&lt;br /&gt;
        if (ptr != IntPtr.Zero) {&lt;br /&gt;
            Marshal.FreeHGlobal(ptr);&lt;br /&gt;
            ptr = IntPtr.Zero;&lt;br /&gt;
            GC.RemoveMemoryPressure(1024);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Free memory: Marshal.FreeHGlobal==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime.ConstrainedExecution;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using Microsoft.Win32.SafeHandles;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        IntPtr ptr = Marshal.AllocHGlobal(1024);&lt;br /&gt;
        if (ptr != IntPtr.Zero){&lt;br /&gt;
                Marshal.FreeHGlobal(ptr);&lt;br /&gt;
                ptr = IntPtr.Zero;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>