In-depth understanding of Java garbage collection mechanismOne: The significance of garbage collection mechanismOne notable feature of the Java language is the introduction of the Java recycling mechanism, which is the most troublesome memory management problem for C + + programmers, which allows
1. OverviewFor developers engaged in C, C + + program development, in the field of memory management, they both have the highest right to the "emperor" is also engaged in the most basic work of the "working people"----have each object of the "ownership", but also assume the life of each object to the end of the maintenance responsibility.For Java programmers, with the help of the automatic
(Allocation Method)
1. pointer collision (Bump the point) ---- the memory in the Java heap is absolutely regular
The memory in the Java heap is absolutely complete, so all the used memory is put on one side, the idle memory is
robust code and solutions1. Free up references to unwanted objects as soon as possible. A good idea is to use a temporary variable, so that the reference variable is automatically set to null after exiting the active domain, implying that the garbage collector collects the object to prevent memory leaks.
The JVM does not reclaim the resource if it still has a pointer to it, because garbage collection takes
1. Heap memory and non-heap memory (non-heap memories)Java virtual machines have a heap, where the heap is a runtime data region, where all class instances and arrays of memory are allocated, heap memory is created at the start of the Ja
the memory space pointed to by the V reference has a reference to the object. This means that although the O reference is already empty, there are still other references to object objects that can be accessed, so the GC cannot release it. If after this loop the object object has no effect on the program, we assume that the Java program has a memory leak. Althou
When reading this article, at least first of all, the concept of the JVM, working principle, structure composition, have certain basic understanding, the nonsense does not say much, this article is straight to the point, directly to work more common concepts: class, Class object, instance object, static method, Non-static method, static attribute, non-static attribute, etc. directly into the use and allocation of JVM memory, through these principles t
Java divides memory into two types, one is called stack memory, the other is called heap memory
Some of the basic types of variables and reference variables defined in the function are allocated in the stack memory of the function. When a variable is defined in a block of co
Directory
I. Background knowledge
Two. Introduction to JVM Virtual machine memory
Three. Garbage collection
Four. Some changes brought about by JAVA7 and 8
For a Java programmer, it is true that in most cases there is no need to think too much about allocating and releasing memory, nor how much understanding the JVM requires. However, in
Q: How can a memory leak be generated in Java?In A:java, there are many reasons for memory leaks. A typical example is a failure to implement Hascode andThe case where the key class of the Equals method is saved in HashMap. A lot of duplicate objects will be generated at the end. All the memory leaksFinally, the OutOfM
of memory: heap and non-heap. Simply put, the heap is the Java code of memory, is left to the "developer", not the heap is the JVM left to itself, so the method area, the JVM internal processing or optimization of the required memory (such as the JIT compiled code cache), each class structure (such as running a consta
virtual machine is started. "" The memory outside the heap in the JVM is called non-heap (non-heap memory) ". You can see that the JVM primarily manages two types of memory: heap and non-heap. In a nutshell, a heap is a Java code-readable memory that is left to the develope
the memory is contempoly.Freememory () is what, just talked about if you run Java without adding-XMS parameters, then, in the Java program running process, memory is always slowly from the operating system dug, basically is how much digging how much, But Java Virtual machin
I. memory overflow type1. java. lang. OutOfMemoryError: PermGen space
JVM manages two types of memory, heap and non-heap. Heap is used by developers. It is created at JVM startup. Non-heap is reserved for JVM and used to store class information. Unlike the heap, GC does not release space during runtime. If the web app uses a large number of third-party jar files
program, we assume that the Java program has a memory leak.Despite the small amount of damage caused by a Java memory leak in the case of memory leaks in C + +, in most cases the program will still run normally, except in the rare case of a program crash. However, when mobi
Defining the Java memory model is not an easy task, and the model must be sufficiently rigorous to allow Java concurrency to be ambiguous, but it must be loose enough to allow the virtual machine's implementation to have enough free space to take advantage of the various features of the hardware (registers, cache, etc.
.
◆ Storage zone: The JVM storage zone is used to store compiled bytecode and other information.
◆ Fragment collection zone: JVM fragment Collection refers to the collection of specific instances of the used Java class from the memory, which enables
Developers are free from the trouble and danger of programming and controlling the
I. memory overflow type1. java. lang. OutOfMemoryError: PermGen spaceJVM manages two types of memory, heap and non-heap. Heap is used by developers. It is created at JVM startup. Non-heap is reserved for JVM and used to store class information. Unlike the heap, GC does not release space during runtime. If the web app uses a large number of third-party jar files o
objects created later. One of the biggest advantages of the Java programming language is automatic garbage collection , unlike other programming languages where you need to manually allocate and free memory, such as the C language. The garbage collector is a background run program. It manages all objects in memory and
specifies the maximum heap memory, which is Jhat-j-xmx512m-port 9998/tmp/dump.dat. Then you can enter the host address in the browser: 9998 viewed7. Java heap space is different from the stack space, and the stack space is used to store the call stack and local variables.8. The Java garbage collector is used to reclaim memor
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.