Did you like how we did? Rate your experience!

4.5

satisfied

46 votes

What are some good Libraries or Frameworks for Memory Management in?

Be aware that the overall performance of your application might not be significantly related to the speed of malloc (because malloc usually is fast enough, and you dont spend much time in it, and having to call free on every malloc-ed value is a big burden too). You need to profile your application to understand if the raw speed of malloc & free is significant (and you might chose some specific faster malloc libraries in these cases). You should perhaps care about fragmentation and avoid memory leaks. Notice that it does depend upon the kind of application you are coding. A small command line utility which runs quickly can (and often does) afford to not care about fragmentation and even memory leaks (some such applications dont even bother to call free). Regarding memory leaks, use valgrind to chase them. In some applications, you may chose to use Boehms garbage collector for C and C++. Then youll use GC_MALLOC & friends for allocations and not bother about free. Be sure to understand the basics of garbage collection technologies and concepts (e.g. read The Garbage Collection Handbook ). There are other GC libraries for C, such as Ravenbrook MPS or even my Qish. Andn some cases you can code your own (for example, the GCC compilers have their internal GC, quite a poor one). So IMHO having a basic culture on GC is essential. Be aware that in some applications, using (or coding) a GC might make them faster than manual management techniques ( la C or C++). For C++, do understand that scope ending matters a lot: much code is executed at closing brackets } (destructors, etc). Read about RAII. Be sure to understand that Reference counting is some kind of (poor and limited) GC technique which does not handle well circularities (however, it works well for tree or DAG like datastructures, such as GUI widgets which dont have circularities). Read about Smart pointers & Weak references. Understand that there is no silver bullet about memory management, so different kind of applications will make various trade-offs, and that memory management & GC is a whole program issue. Notice also that because of the CPU cache, Locality of reference is a very important issue performance-wise, and may impact the choice of containers and of algorithms you are using.

100%
Loading, please wait...