# C1.Util.DX.DXUtil.AllocateClearedMemory

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_DXUtil_AllocateClearedMemory_" data-uid="C1.Util.DX.DXUtil.AllocateClearedMemory*">AllocateClearedMemory Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_DXUtil_AllocateClearedMemory_" data-uid="C1.Util.DX.DXUtil.AllocateClearedMemory*"></a>
<h4 id="C1_Util_DX_DXUtil_AllocateClearedMemory_System_Int32_System_Byte_System_Int32_" data-uid="C1.Util.DX.DXUtil.AllocateClearedMemory(System.Int32,System.Byte,System.Int32)">AllocateClearedMemory(int, byte, int)</h4>
<div class="markdown level1 summary"><p>Allocate an aligned memory buffer and clear it with a specified value (0 by default).</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IntPtr AllocateClearedMemory(int sizeInBytes, byte clearValue = 0, int align = 16)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function AllocateClearedMemory(sizeInBytes As Integer, Optional clearValue As Byte = 0, Optional align As Integer = 16) As IntPtr</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">sizeInBytes</span></td>
      <td><p>Size of the buffer to allocate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a></td>
      <td><span class="parametername">clearValue</span></td>
      <td><p>Default value used to clear the buffer.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">align</span></td>
      <td><p>Alignment, 16 bytes by default.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.intptr">IntPtr</a></td>
      <td><p>A pointer to a buffer aligned.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_DXUtil_AllocateClearedMemory_System_Int32_System_Byte_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>To free this buffer, call <a class="xref" href="C1.Util.DX.DXUtil.FreeMemory.html#C1_Util_DX_DXUtil_FreeMemory_System_IntPtr_">FreeMemory(IntPtr)</a>.</p>
</div>
</div>
