in the heap space. I try my best to write down all the knowledge I know about heap. I also hope that you can contribute as much as possible and share your knowledge so that other people can benefit from it.
What is the heap space in Java?When the Java program starts to run, the JVM obtains some memory from the operating system. The JVM uses these memories, part of which is the heap memory. The heap memory
. Classpool;import javassist. Ctclass;import javassist. Notfoundexception;public class Testoneclassload {static Myclassloader C1 = new Myclassloader ();p ublic void Testoneclassload () throws Cannotcompileexception, Notfoundexception, Instantiationexception, IllegalAccessException {for (int i = 0; i There will be no problem with the above.JVM Memory allocation parameters1. Setting the maximum heap memorySpecified using the-XMX parameter. The maximum h
implement a fixed or scalable Virtual Machine. However, all current commercial virtual machines are implemented according to scalability (controlled by-Xmx and-Xms ). If memory cannot be allocated in the heap and the heap cannot be expanded, an OutOfMemoryError error will be thrown.
5. Method Area)
The "Method Area" may not have many people who know it. If it is called "Permanent Generation", there may be more fans. It also has an alias called Non-He
Recently, you want to test the maximum concurrent number under OpenFire, you need to open a large number of threads to simulate the client. There are a number of questions about how many threads can open in a JVM instance, so it's time to actually test, simply Google, and find the following factors that affect the amount of threads:
-xms
intial java Heap Size
-xmx
Maximum
vor space. from the perspective of memory Allocation, the Java pairs shared by threads may be divided into private Allocation buffers (Thread Local Allocation Buffer, TLAB) for multiple threads ). however, no matter how it is divided, it is irrelevant to the storage content. No matter which region it is stored, it is still an object instance. The purpose of further division is to better recycle the memory, or allocate memory faster.
3) According to t
the two snapshots to see which objects have increased in quantity from the first snapshot to the second snapshot. Because you force the garbage collection before the snapshot, the rest will be all objects referenced by the application, comparing two snapshots accurately identifies the newly created objects that are retained in the application. Based on your understanding of the application, you can determine which objects are unintentionally retaining object references in two snapshot compariso
. Parallel collectorThe parallel collector uses some traditional algorithms and uses multithreading to perform their work in parallel. The use of multithreading on multi-CPU machines can significantly improve the scalability of Java applications.3.Sun HotSpot 1.4.1 JVM Heap Size adjustmentSun HotSpot 1.4.1 uses a generational collector, which divides the heap into three main domains: new, old, and permanent. All new objects generated by the JVM are pl
generation, the new generation can be divided into two types: Eden space and javascor space. The Eden space stores new objects. After garbage collection, the new objects will be stored in the same vor space, when the ratio of the surviving objects in the same vor space to the Eden space exceeds a certain number, some objects will be placed in the old age area, and the method area will be permanently replaced. According to the java Virtual Machine spe
is related to the operating system, the general 32-bit machine is between 1.5g and 3g, and 64-bit will not be limited.Note: If XMS exceeds the XMX value, or if the sum of the heap maximum and the non-heap maximum exceeds the physical memory or the maximum operating system limit, the server will not start up.Garbage collection GC:The frequency with which the JVM calls the GC is still high, with garbage collection in two main cases:When the application
Tomcat Xms Xmx permsize maxpermsize Difference and java.lang.OutOfMemoryError:PermGen space solutionSolution added in front of the blue Code in Catalina.bat: Red codeSet java_opts=%java_opts%-server-xms800m-xmx1024m-xx:permsize=128m-xx:maxpermsize=256m echo Using catalina_base: "%catalina_base%" Here is a description of the difference: Excerpt from: http://www.cnblogs.com/mingforyou/archive/2012/03/03/2378143.htmlEclipse crashes, error message:M
heap when the heap is insufficient and upgrades the young area to the older area.
The size of the older area is equal to-xmx minus-xmn, and the value of-XMS cannot be set too large, because the second thread is forced to run will reduce JVM performance.Why?ProgramFrequent GC?
There are the following reasons:1. The program calls system. GC () or runtime. GC ().2. Some middleware software calls its own GC method. In this case, you need to set parame
the JVM.
When we create objects, they are stored in the Java heap memory.
To facilitate garbage collection, the Java heap space is divided into three zones, called New Generation, old Generation or tenured Generation, and perm space.
You can resize the Java heap space by using the Jvm's command-line Options-xms,-
compression may be involved here to free up enough space for large objects.
JVM parameters related to garbage collection:
²-Xms/-Xmx --- initial heap size/maximum heap size
²-Xmn --- size of the young generation in the heap
²-XX:-DisableExplicitGC --- so that System. gc () does not have any effect
²-XX: + PrintGCDetail --- print GC details
-XX: + PrintGCDateStamps --- print the GC operation Timestamp
31. String s = new String ("xyz"); how many Strin
compilation period.
Direct MemoryDirect memory is not part of the data area when the virtual machine is running, nor is the memory area defined in the Java VM Specification, which is an area of memory outside the JVM, which can also cause outofmemoryerror exceptions.
JVM parameters-XSS (stackspace) stack space-XMS,-xmx (heap memory space) heap space: Heap is the most familiar area, he is the area
the heapThe second thread traverses the heap when the heap is insufficient, and upgrades the young area to the older areaThe size of the older area is equal to-xmx minus-xmn, and the value of the-XMS cannot be set too large because the second thread is forced to run to degrade the performance of the JVM.Why do some programs frequently occur in GC?There are the following reasons:1. System.GC () or RUNTIME.GC () is called within the program.2. Some mid
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 constant pool, field and method data) And the code for methods and construction methods are in non-heap memory. 2) heap memory allocation JVM
In some slightly larger applications, the memory settings of the Java Virtual Machine (JVM) are particularly important, and the GC (garbage collection) setting is the first step in trying to achieve good efficiency in the project.PermGen space: The full name is permanent Generation space. is a permanently saved area for storing class and meta information, and class is placed in the area of heap space when it is loaded: storage instance.The GC (garbage
snapshot. Because you force the garbage collection before the snapshot, the rest will be all objects referenced by the application, comparing two snapshots accurately identifies the newly created objects that are retained in the application.Based on your understanding of the application, you can determine which objects are unintentionally retaining object references in two snapshot comparisons.Track the leading references and find the objects that are referencing these unintentional holding obj
scalability issues.Because performance tuning is still the primary way to solve the problem of Java scalability, let's start by looking at the main tuning parameters and what they can achieve.Tuning parameters: Some examplesThe most famous tuning parameter is "-XMX", which allows you to specify the heap size of Java, which may actually vary from JVM execution to
in which deployment architecture. Large Application Server deployment scenario (Image source: Azul Systems) Large Application Server deployment scenario (Image source: Azul Systems) As I said before, concurrent compression makes the large application server deployment mode feasible and can break the limits of JVM scalability. At present, only the Azul Zing JVM can provide concurrent compression technology, and Zing is the server side of the JVM, we are happy to see more and more developers at
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.