0% found this document useful (0 votes)
28 views1 page

Java 2

Java features automated memory management through a garbage collector that frees up memory from unused objects, eliminating memory leak issues common in C and C++. Unlike C and C++, where programmers must manually manage memory allocation and deallocation, Java simplifies this process. Additionally, Java uses references instead of pointers, providing safer access to memory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

Java 2

Java features automated memory management through a garbage collector that frees up memory from unused objects, eliminating memory leak issues common in C and C++. Unlike C and C++, where programmers must manually manage memory allocation and deallocation, Java simplifies this process. Additionally, Java uses references instead of pointers, providing safer access to memory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

java2

Transcribed by TurboScribe.ai. Go Unlimited to remove this message.


Why Java? Part 2. In Java, we have something called as automated memory management.
Whenever a program is running, a process is created and the memory is allocated to that
process, right? So in that memory, heap area is very crucial. So managing that heap area is
very important because the size is limited and that depends on the operating system.

So in C, C++, we have dynamic memory allocation but does not have a concept of dynamic
memory deallocation. So the programmer has to take care of memory deallocation to the
objects whenever the objects are no longer required. So the programmer has to manage
well else the memory is occupied by the object so we cannot create new object because of
no spatial issue and this is called memory leak problem in C, C++.

While in Java, we don't have that problem. Why? Because in Java, the beauty is we have a
background process or a facility called garbage collector and while our program is running in
background, one more program is running in the background that is called garbage
collector. At a regular interval of time, this garbage collector will check the memory and if
there are any unused object, it will free up the memory.

So there is no problem of memory leak in Java. Second, in Java, we don't have a concept of
pointers because pointers have direct access to memory and which is unsafe but in Java, we
have something called as references which is closer to pointers but it is safe.
Transcribed by TurboScribe.ai. Go Unlimited to remove this message.

You might also like