Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Unless your application is multithreaded you probably shouldn't bother. <a href="http://developers.sun.com/solaris/articles/multiproc/multiproc.html" rel="nofollow noreferrer">This article suggests (for one platform, at least) that <code>malloc</code> performs quite competitively in a single threaded environment</a>.</p> <blockquote> <p>So, which allocator should you use in your application? <code>malloc</code> on the Solaris OS was shown to be a strong choice for single-threaded code.</p> <p><img src="https://i.stack.imgur.com/2A6mv.gif" alt="Note the first case"></p> <p><img src="https://i.stack.imgur.com/zke7L.gif" alt="Note the first case"></p> </blockquote> <p>You'll be hard pressed to do better than <code>malloc</code> or its very similar functions. If you want better memory allocation you can wrap <code>malloc</code> or call the operating system memory allocation functions (but lose out on portability) and place your own allocation logic on top of chunks of memory.</p> <p>If you <em>really</em> need a better memory allocator, try <a href="http://www.hoard.org/" rel="nofollow noreferrer">Hoard</a>:</p> <blockquote> <p>The Hoard memory allocator is a fast, scalable, and memory-efficient memory allocator for Linux, Solaris, Mac OS X, and Windows. Hoard is a drop-in replacement for malloc that can dramatically improve application performance, especially for multithreaded programs running on multiprocessors and multicore CPUs.</p> <p><img src="https://i.stack.imgur.com/m8Sxi.gif" alt="Benchmark"></p> </blockquote> <p>Note that <a href="http://plasma.cs.umass.edu/emery/licensing-hoard" rel="nofollow noreferrer">it's not necessarily free</a>. If you want a free one, try <a href="https://stackoverflow.com/questions/147298/multithreaded-memory-allocators-for-c-c">one of these</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload