<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Heap Allocation on AI VOID</title><link>https://ai-blog.noorshomelab.dev/tags/heap-allocation/</link><description>Recent content in Heap 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/heap-allocation/index.xml" rel="self" type="application/rss+xml"/><item><title>Chapter 17: Guided Project: Custom Memory Allocator</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/project-custom-memory-allocator/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/project-custom-memory-allocator/</guid><description>&lt;h1 id="chapter-17-guided-project-custom-memory-allocator"&gt;Chapter 17: Guided Project: Custom Memory Allocator&lt;/h1&gt;
&lt;p&gt;This project takes you deep into the heart of low-level C programming: &lt;strong&gt;memory management&lt;/strong&gt;. You&amp;rsquo;ve used &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt; extensively, but have you ever wondered how they work? In this guided project, you will build a simplified version of a memory allocator.&lt;/p&gt;
&lt;p&gt;This project is significantly more complex than the calculator but offers unparalleled insights into:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pointers and Pointer Arithmetic:&lt;/strong&gt; Extensive use of raw memory addresses.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structures:&lt;/strong&gt; To define memory block metadata.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamic Memory Allocation:&lt;/strong&gt; Understanding &lt;code&gt;sbrk()&lt;/code&gt; (or similar system calls) for getting raw memory from the OS.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory Layout:&lt;/strong&gt; How memory is organized and managed at a low level.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error Handling:&lt;/strong&gt; Crucial for robust memory management.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This will be a &lt;em&gt;very basic&lt;/em&gt; allocator. Real-world &lt;code&gt;malloc&lt;/code&gt; implementations are highly optimized and complex, involving techniques like freelists, memory pools, mutexes for thread safety, and elaborate block splitting/merging algorithms. Our goal is conceptual understanding.&lt;/p&gt;</description></item></channel></rss>