How to monitor Windows memory usage for Java applications

Source: Internet
Author: User
Tags memory usage reserved

One of the best known advantages of Java technology is that, unlike other languages such as C programmers, Java programmers do not have to be responsible for daunting memory allocations and releases. The Java runtime can manage these tasks for you. Each instantiated object automatically allocates memory in the heap, and the garbage collector periodically reclaims the memory occupied by objects that are no longer in use. But you're not completely out of it. You still need to monitor the memory usage of your program, because the Java process's memory includes more than just the objects that are allocated in the heap. It also includes the program's bytecode (the JVM interprets execution instructions at run time), JIT code (code that has been compiled for the target processor), any native code, and some metadata (exception table, row number table, and so on) used by the JVM. More complicated, some types of memory, such as native libraries, can be shared between processes, so determining the memory footprint of a Java application can be a daunting task.

There are plenty of tools for monitoring memory usage in Windows, but unfortunately no one can provide all the information you need. To make things worse, these various tools do not even have a common vocabulary. But this article will help you by introducing some of the most useful tools available for free, and providing tips on how to use them.

Windows Memory: A whirlwind trip

Before you understand the tools that are discussed in this article, you need to have a basic understanding of how Windows is managed. Windows uses a paging request virtual memory system, and now we're going to analyze the system.

Virtual address space

The concept of virtual memory was proposed in the 50 's, and was proposed as a solution to the complex problem of the process of not loading the actual memory at once. In virtual memory systems, programs can access a larger set of addresses that exceed available physical memory, and the dedicated memory management program maps These logical addresses to the actual addresses and uses temporary storage on the disk to save the excess.

In modern virtual memory implementations used by Windows, virtual storage is organized into units of the same size, called pages. Each operating system process consumes its own virtual address space, a set of virtual memory pages that can be read and written. There are three states of each page:

Freedom: No process has yet used this part of the address space. If you attempt to access this part of the space, both read and write will cause some run-time failure. This action will cause a Windows dialog box to pop up, prompting an access violation. (Java programs do not cause this error, and only programs written in a language that supports pointers can cause this problem.) )

Reserved: This part of the address space is reserved for future use, but cannot be accessed until it is delivered. Many Java heaps are in a reserved state at first.

Commit: The memory that the program can access is fully supported, which means that the page frame has been allocated in the paging file. The submitted page is loaded into main memory only the first time it is referenced, so it becomes a request paging.

Figure 1 illustrates how a virtual page in the process address space maps to a physical page frame in memory.

Figure 1. Mapping of virtual pages to physical page frames in the process address space

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.