<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dynamic Allocation on AI VOID</title><link>https://ai-blog.noorshomelab.dev/tags/dynamic-allocation/</link><description>Recent content in Dynamic Allocation on AI VOID</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 03 Nov 2025 01:00:00 +0000</lastBuildDate><atom:link href="https://ai-blog.noorshomelab.dev/tags/dynamic-allocation/index.xml" rel="self" type="application/rss+xml"/><item><title>Chapter 7: Memory Management: `malloc`, `calloc`, `realloc`, `free`</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/memory-management/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/memory-management/</guid><description>&lt;h1 id="chapter-7-memory-management-malloc-calloc-realloc-free"&gt;Chapter 7: Memory Management: &lt;code&gt;malloc&lt;/code&gt;, &lt;code&gt;calloc&lt;/code&gt;, &lt;code&gt;realloc&lt;/code&gt;, &lt;code&gt;free&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;Up until now, all the variables we&amp;rsquo;ve used have been allocated automatically by the compiler in either &lt;strong&gt;static memory&lt;/strong&gt; (for global variables) or the &lt;strong&gt;stack&lt;/strong&gt; (for local variables and function parameters). This is sufficient for many tasks, but it has limitations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fixed Size:&lt;/strong&gt; Stack-allocated arrays (like &lt;code&gt;int arr[10];&lt;/code&gt;) must have their size known at compile time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Limited Lifetime:&lt;/strong&gt; Stack variables are automatically destroyed when their function exits.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Dynamic Memory Allocation&lt;/strong&gt; allows your program to request memory from the operating system during runtime (when the program is executing) from an area called the &lt;strong&gt;heap&lt;/strong&gt;. This memory persists until explicitly deallocated or the program ends. This is crucial for:&lt;/p&gt;</description></item></channel></rss>