IDEA memory debugging plug-in (easy to use) and idea memory debugging plug-in

Source: Internet
Author: User

IDEA memory debugging plug-in (easy to use) and idea memory debugging plug-in

JetBrains JVM Debugger Memory View plugin

During my recent R & D activities, I sought new tools to improve my development experience and make the life of Android Studio easier. I found a useful plug-in that I have never heard. That's why I decided to write this powerful tool and how it helps me debug my applications with memory.

What is the plugin about?

According to plugin page:

This plug-in extends the built-in JVM debugger to observe the objects in the JVM heap during debugging sessions.

The memory view is displayed by class name grouping.Total number of objects in the heap.

When you debug the code step by step, the "Diff" column shows the change in the number of objects between the debugger's stop points (debugger stops, that is, the debug point. In this way, you can easily see how your stepping code affects the heap.

Double-click the class name to open a dialog box containing the class instance. This dialog box allows youFilter by computing expressionInstance. All debugger operations (such as checking, marking objects, evaluating expressions, and adding to observation) can be applied to instances in this dialog box.

How to install this wonderful plugin?

Open the Android Studio Plugins page:

  • Shortcut Key: Press command/ctrl + shift + A, type plug-in subsequently, press enter:
  • Or open Preferences/Settings: (Mac: Android Studio-> Preferences/Windows and Linux: File-> Settings) and find the Plugins page:

Press Install jetBrains plugin... Click to search for JVM Debugger Memory View and then Install.

Restart Android Studio after installation.

At first glance:

After returning to Android Studio, you will find that the Memory View Tool Window has been added to the right of the toolbar.

Memory View Tool Window

Memory View tool window

If the Memory View is not displayed, open the Tool window and use the main menu: View → Tool Windows → Memory View.

First, the tool displays data only when debugging breakpoint is triggered and running in debug mode.

Secondly, I want to mention that I have read some warnings and errors that may occur in Android Studio, but I have never encountered them.

Warning the Android Studio version has the following restrictions:

  • Due to the memory limit of Android, obtaining a large number of instances may fail and the VM will be stopped.
  • Android Studio may stop responding. See this error.

Let's debug!

After you run the application in debug mode and pause it on the BreakPoint, you will see a magic picture:

This table is most interested in the Diff column. When you debug code step by step, you will see how many new object instances will be created or destroyed!

I want to find my own object (that is, the ProfileModel class), So I search for it:

As you can see, I have updated the ProfileModel vairable in this line of code. Before GC deletes the old object, I get the difference of + 1. I can also access the old object that was not previously accessible. By double-clicking this record, I will get the instance of the ProfileModel class in the window:

This window also allows you to use the class method to filter instances by computing expressions. For example, you can use the isSuccessful method of the OkHttp Response class to filter the responses that fail to be loaded in the memory:

Instance Filter Function

Another useful feature is to track new instances. You can enable it through the context menu in the Memory View Tool window:

This feature helps you track the code of new instances of generated classes!

The above is the IDEA memory debugging plug-in introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in time. Thank you very much for your support for the help House website!

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.