Review: JDK and JRE

What is it for?

Jdk is used by developers, and java programs can be developed with jdk.

Jre is used to run programs, jre includes jvm, JVM is a virtual machine for running Java programs, but running Java programs requires not only the core virtual machine, but also other environments

 

Reclaim memory

Displaying the recovery will cause the program to be paralyzed by forgetting to recover, or the memory of the core library will be recovered during recovery, which will cause the system to crash.

JRE can automatically reclaim memory:

When will it be recycled?

When there is no reference variable pointing to the memory originally allocated to an object.

That is, when an object is no longer referenced, the memory reclaims the space occupied by it.

Pros and cons

1. What is recovered is the memory space of useless objects, and there is nothing to do with physical resources (database connection, disk I/O)

2. There are many garbage collection algorithms, you can understand some properly. So the recovery time will be uncertain, when the cpu is idle, timing, or when the memory consumption reaches a certain level.

3. The current garbage collection mechanism can realize multithreading.

Guess you like

Origin blog.csdn.net/sulu0416/article/details/88627338