# C1.Util.DX.DXUtil.AllocateMemory

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_DXUtil_AllocateMemory_" data-uid="C1.Util.DX.DXUtil.AllocateMemory*">AllocateMemory Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_DXUtil_AllocateMemory_" data-uid="C1.Util.DX.DXUtil.AllocateMemory*"></a>
<h4 id="C1_Util_DX_DXUtil_AllocateMemory_System_Int32_System_Int32_" data-uid="C1.Util.DX.DXUtil.AllocateMemory(System.Int32,System.Int32)">AllocateMemory(int, int)</h4>
<div class="markdown level1 summary"><p>Allocate an aligned memory buffer.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static nint AllocateMemory(int sizeInBytes, int align = 16)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function AllocateMemory(sizeInBytes As Integer, 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.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">nint</a></td>
      <td><p>A pointer to a buffer aligned.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_DXUtil_AllocateMemory_System_Int32_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(nint)</a>.</p>
</div>
</div>
