Quote:
Originally Posted by dmjpro
Well, I disagree here ;)
When the program gets compiled and ready to start in native OS, then OS initializes the process block and etc ..what the process needs to run.
When the process claims a memory block then OS gives from it's own area which is shared by other process. Now when process ends then how do OS knows that memory blocked initialized by that particular process?
And this is what the difference between Java(run time system other than OS) and C or C++(runtime system OS itself). And in Java memory leaks is not concerned ;)
You are wrong; a block of memory claimed by the process belongs to the process and no other process can access it (*) (a segmentation violation will be the result) and the OS very well knows what memory belongs to which process. When the process finishes the OS reclaims all memory used by the process. Especially virtual memory handled by the hardware itself (memory management units) truly eases this task.
Even old MSDOS knew how to reclaim memory from died processes. Memory leaks are also a concern in Java: memory (objects) can still be reachable and thus won't be reclaimed by the garbage collector. Read the 'Weak References' article in the 'Insights' section.
kind regards,
Jos
(*) except for shared memory but it needs to be claimed as such.