Java application dead Loop troubleshooting method or lookup program consuming resource thread method

Source: Internet
Author: User

What if I encounter a spike in online application CPU and what happens to Outofmemery?

First, the JVM configuration of the online application to develop a good habit, add a configuration to automatically dump the log when the JVM has an oom-xx:+heapdumponoutofmemoryerror-xx:heapdumppath=/export/log /dump/jvm-oom.log

How do I troubleshoot an online application that consumes CPU resources in particular?

PS: First of all, the Java Virtual machine thread implementation in Linux: Under Linux because there is no real thread, is simulated with the process, there is a worker thread, so the real program to open the thread should only one.
First, view the Java processuse JPS or Ps-ef to find the appropriate Java processor use top to view the process where the machine consumes a high CPU ratio (process number: 13408)Second, use Top-h view Thread, process number: 134,323, the thread number: 13432 into 16 binary: 34,784, view dump file or use Jstack <pid> | grep < hex Sub-process number >the difference between threads and processes is an additional common: Thread: refers to an execution unit within a process, and is also a scheduled entity within a process.Differences from the process:

(1) Address space: An execution unit within a process; The process has at least one thread; they share the address space of the process, and the process has its own independent address space;
(2) Resource ownership: A process is a resource that is allocated and owned by a thread in a process that shares the resources of the process
(3) The thread is the basic unit of the processor dispatch, but the process is not.
4) Both can be executed concurrently.

Processes and threads are the basic units that the operating system realizes, and the system uses this basic unit to realize the concurrency of the system to the application. The difference between a process and a thread is:

In short, a program has at least one process, and a process has at least one thread.
The thread's dividing scale is smaller than the process, which makes the multi-thread procedure high concurrency.
In addition, the process has a separate memory unit during execution, and multiple threads share memory, which greatly improves the efficiency of the program operation.
Threads are still different from the process during execution. Each separate thread has a program run entry, sequence of sequence execution, and exit of the program. However, threads cannot be executed independently, and must be dependent on the application, which provides multiple threads of execution control.
From a logical point of view, the meaning of multithreading is that in an application, multiple execution parts can be executed concurrently. However, the operating system does not consider multiple threads as separate applications to implement scheduling and management of processes and resource allocation. This is the important difference between processes and threads.

A process is a program with a certain independent function about a single run activity on a data set, a process that is an independent unit of the system's resource allocation and scheduling.
A thread is an entity of a process that is the basic unit of CPU dispatch and dispatch, which is a smaller unit that can run independently than a process. The thread itself basically does not own the system resources, only has a point in the operation of the necessary resources (such as program counters, a set of registers and stacks), However, it can share all of the resources owned by the process with other threads that belong to one process.
One thread can create and revoke another thread, and can execute concurrently between multiple threads in the same process.

Java applies a dead loop method or a lookup program consumes a resource in a thread method

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.