jmap

jmap -dump:format=b,file=String 3024 can output the memory heap of the 3024 process to a String file.

jstack -F 1282

jmap -heap 1282

PermGen space: The full name is Permanent Generation space, the permanent generation. That is to say, it is a permanently saved area for storing Class and Meta information. Class is put into this area when it is loaded. GC (Garbage Collection) should not clean up the PermGen space, so if your APP will load a lot If CLASS is used, PermGen space error is likely to occur.
Heap space: Store Instance. Java Heap is divided into 3 areas, Young is the new generation, Old is the old generation and Permanent. Young holds the object that was just instantiated. When the area is filled, the GC will move the object to the Old area. The Permanent area is responsible for saving the reflection object.

top –H –p pid
84784 appdeplo 20 0 4518m 1.1g 3816 S 0.4 29.0 0:00.85 java

needs to convert the thread number displayed by the top command to hexadecimal, take 15100 as an example, enter the command under linux: printf 0x%x 15100, get the hexadecimal of 15100 as 0x3afc

Dump out all thread stacks of the process, use the command "./jstack -F -m -l 84703 > 84703.stack"
, the nid in the first line is the hexadecimal converted earlier System numbers, all threads have such a corresponding thread stack.

jstack 27698 > jstack27698.txt is consistent with nid and is found. The

stack

is also called stack memory. It is the running area of ​​Java programs. It is created when the thread is created. Its life cycle follows the life cycle of the thread. When the thread ends, the stack memory is released Method Area The
method area is shared by all threads. This area saves all fields and method bytecodes, as well as some special methods such as constructors, and the interface code is also defined here.
q PC Register program counter
Each thread has a program counter, which is a pointer to the method bytecode in the method area, and the next instruction is read by the execution engine.
q Native Method Stack Native method stack

Q : What is the difference between the heap and the stack?
A: The heap stores objects, but the temporary variables in the objects are stored in the stack memory. For example, the methodVar in the example is stored in the stack during runtime.
The stack follows the thread. If there is a thread, there is a stack. The heap follows the JVM. If there is a JVM, there is heap memory.
Static variables are stored in the method area, and instance variables are stored in heap memory.

Heap and Method Area are shared, others are private,

constant pool (constant pool): an area where constants in the program are stored in order and indexed. For example int i = 100, this 100 is placed in the constant pool.
Security Manager: Provides Java runtime security control to prevent malicious attacks, such as specifying permissions to read files, write files, network access, create processes, etc. Class Loader can load classes only after Security Manager authentication is passed file.
The Methods table records the address information of each method. The address pointers in Stack and Heap actually point to the Methods table address.

When a thread accesses an object's synchronized(this) synchronized code block, it acquires the object's object lock. As a result, other threads' access to all synchronized parts of the object object is temporarily blocked.

map(), spill, merge, shuffle, sort, reduce()
Spark's shuffle mainly has two stages: Shuffle Write and Shuffle Read.

jmap -dump:live,format=b,file=heap.txt 24837
jmap -dump:format=b,file=jmapformat.txt 24837

jmap -F -dump:format=b,file=tomcat.bin 9142


jhat heap.txt

http://localhost:7000, you can view
detailed memory information


AbstractQueuedSynchronizer accommodates all blocked threads by constructing a blocking-based CLH queue, and operations on the queue are performed through Lock-Free (CAS) operations, but for those that have already obtained In terms of lock threads, ReentrantLock implements the function of biased locks.

BlockingQueue
offer(anObject): Indicates that if possible, add anObject to the BlockingQueue, that is, if the BlockingQueue can accommodate it, return true, otherwise return false. (This method does not block the thread currently executing the method)
offer(E o, long timeout, TimeUnit unit), you can set the waiting time. If the BlockingQueue cannot be added to the queue within the specified time, it will return a failure.
  put(anObject): Add anObject to the BlockingQueue. If there is no space in the BlockingQueue, the thread calling this method will be blocked until there is space in the BlockingQueue to continue.

Get data
poll(time): Take the object in the first place in the BlockingQueue , If you can't take it out immediately, you can wait for the time specified by the time parameter, and return null if you can't take it;
  poll(long timeout, TimeUnit unit): Take out a queue head object from the BlockingQueue, if the queue has data within the specified time Desirable, the data in the queue is returned immediately. Otherwise, if the time expires and there is no data available, return failure.
  take(): Take the object ranked first in the BlockingQueue, if the BlockingQueue is empty, block and enter the waiting state until new data is added to the BlockingQueue;

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326910225&siteId=291194637