Memory Allocation
&gt; When we free memory, we should make sure that if the block we return to the free list is next to any other free blocks, we combine them together. This is called &quot;coalescing.&quot;<p>A little offtopic but the default Delphi 7 memory allocator did this, except that it also merged blocks that it obtained from different OS allocation calls.<p>This worked fine for regular usage, but if that memory was ever used for Bitmaps for UI stuff, it wouldn&#x27;t work: Since Windows does some of its UI stuff in kernel mode, before doing anything Windows would attempt to lock the entire allocation&#x27;s VAD entry to prevent you from messing with it in another thread while it was using it. If the Bitmap you were working on happened to belong to two different OS-level allocations, this lock function would fail since it wasn&#x27;t meant to handle that case.<p>This would lead to random, extremely cryptic errors such as ERROR_NO_SCROLLBARS &quot;The window does not have scroll bars.&quot; since the lock call was deep in the stack and the callers replaced the error with another one as it bubbled up.<p>In the end we had to replace the allocator to avoid that issue. That was a fun day I spent debugging that.