the dynamic memory allocator is a layer between


The dynamic memory allocator is a layer between the application and the OS, managing heap objects. When a program requests memory from the allocator (via malloc(), for instance), the allocator will return a pointer (or reference) to a piece of memory of the appropriate size. When the program is done with the memory, the memory should be released back to the allocator. Languages such as C and C++ leave this job to the programmer to perform manually, for example by using free(). On the other hand, languages such as Java, python, etc automatically manage dynamically-allocated memory, which makes the programmer's life easier, and can eliminate entire classes of memory management bugs.

Although using free() and delete is relatively simple, it can be tricky to get them right. A signi?cant fraction of bugs in C and C++ programs are related to manual memory management. If we forget to free objects, we end up with memory leaks; if we free memory too soon, we end up with "dangling pointers"; also, we can try to do weird things, like performing double frees, etc. Therefore, a process that manages memory automatically is clearly useful. The most important concept for correctly implementing a garbage collector is that of live objects: a live object is any object that can still be reached through one (or more) pointers.

Request for Solution File

Ask an Expert for Answer!!
Operating System: the dynamic memory allocator is a layer between
Reference No:- TGS0210551

Expected delivery within 24 Hours