Garbage collection, Operating System

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.

Posted Date: 3/13/2013 2:50:48 AM | Location : United States







Related Discussions:- Garbage collection, Assignment Help, Ask Question on Garbage collection, Get Answer, Expert's Help, Garbage collection Discussions

Write discussion on Garbage collection
Your posts are moderated
Related Questions
FIRST FIT ALGORITHM Scanning a list along with if a free hole is available with necessary space for the process to allocate it allocates the process in that space. The first s

Suppose your process starts up, and allocates some memory with malloc(). The allocator will then give part of a memory page to your process. The OS then updates the corresponding p

Q. Segmentation is alike to paging but uses variable-sized "pages". Describe two segment-replacement algorithms based on FIFO and LRU page replacement schemes. Remember that since

Question 1 Explain (a) tightly coupled systems                               (b) Loosely coupled system Question 2 Describe the RPC model Question 3 Write a note o

Determine a parser which is a variant of top-down parsing without backtracking Recursive Descend parser is a variant of top-down parsing without backtracking.

Q. Presume that you have coded the deadlock-avoidance safety algorithm as well as now have been asked to implement the deadlock-detection algorithm. Can you do thus by simply usin

How can the deadlock be prevented-Safe State Safe state : A state is safe if the system is able to allocate resources to each process in some order and still avoid deadlock.

Locks (also known as mutexes, short for mutual exclusion locks) provide mutual exclusion to shared data inside a critical session. They are implemented by means of two atomic routi

Write in brief on UNIX file structure. UNIX considers every file to be a sequence of 8-bit bytes no interpretation of these bits is made by the operating system. This system pr

Define the Jobs which are admitted to the system for processing is called The Jobs which are admitted to the system for processing is known as long-term scheduling.