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
What are three conditions that a solution for the critical section problem must satisfy? The three conditions are as following:- a)      Mutual exclusion :- if a process is

what are the overall concepts of deadlock

What are two differences among user-level threads and kernel-level threads? Under what circumstances is one type better than the other? (1) User-level threads are unknown by th

What are the disadvantages of linked allocation? The drawbacks are a. Used only for sequential access of files. b. Direct access is not supported c. Memory space neede

Q. Why would it be an awful idea for gateways to pass broadcast packets between networks? What would be the merite of doing so? Answer: All broadcasts would be spreads to all

What is the use of FIFOs in client-server applications

Define Properties to Ensure Good Search Performance A hashing function h should possess the subsequent properties to make sure good search performance: a. The hashing functi

what is meant by lazzy swapper

What are over lays? If a large process enters which is huge than the available memory we are able to use overlays. In this we can divide process into pieces .which is recognize

define semaphore. how can we use semaphore to deal with n-process critical section problem.