Record of the event resolution process of slow project startup/unable to start in Intellij IDEA debug mode

The project could not be started

Briefly introduce the event process: On Monday morning, I received a task thrown by a front-end colleague, saying that an interface could not return data normally, so I asked him to send the parameters. I want to try to reproduce it locally and put the The problem is fixed. In this case, it is definitely necessary to quickly locate the problem through debug. However, after clicking the debug button on IDEA, the project has been unable to start the project normally, and the log can also be seen on the console, but it is basically after a few steps. I can't go on any more, I can't start the project normally after repeated attempts, the log stops after the output of the specific sentence, and the debugging code is even more impossible to talk about.

mengbi

What caused it?

Since this is the first time I encountered this problem, I don't know what the reason is. I just remember that I repeatedly tried the clean install of the project several times, but the results of these several rebuilds and restarts were invalid. Still can't start in debug mode.

I'm also a little dizzy, but the code is definitely ok, because I haven't changed the code at all, I also think it should be a small problem with the settings, but I don't know where the problem is, so I pass the run button. Start the project to verify that it started successfully. This also means that there is no problem with the project and code. It must be a problem with a certain setting item in IDEA, which was not set properly or was accidentally changed by me.

Then I asked my colleagues and friends if they had encountered similar problems, but they all said they had never encountered them, and the front-end colleagues urged them more urgently. After all, going online is the most important thing, so I didn't struggle with this problem, so I pulled the code to On the mac, debug debugging on the mac can be done on the mac, which is even more embarrassing. What is the reason? Is there something wrong with the windows system...

Method Breakpoints

After solving the interface problem of the front-end colleague, I quickly folded back to solve this problem. What is going on!

I checked the Internet and found that other friends have encountered similar problems, and the solutions are similar. It is because there are breakpoints in the project that hit the method, so the debug is slowed down. The solution is also simple, just remove the breakpoint on the method, so I checked whether the breakpoint in my code has a similar situation, and sure enough, I found two breakpoints on the method:

log

After removing these breakpoints on the method, the console immediately started to swipe the log, and the problem that the project could not be started in the debug mode was solved.
Method Breakpoints

For how to view all breakpoints in IDEA, please refer to the previous article " Intellij IDEA View All Breakpoints "

Review

Although this problem has been solved, I am still not very clear about the specific reasons. First of all, why does this happen, and more importantly, why the method breakpoint will cause the project to fail to start at all.

Although this matter is not big, at that time, I really felt that I was in trouble. At that time, I already felt that it was not very easy to deal with this matter. Why? Because this is neither a code problem, nor a technical problem, nor a business problem, how should I put it, this is a sudden problem and a relatively unexpected problem, and more importantly, it has troubled me for a while, So I have to find out why!

It took a day. I encountered this situation in the morning, and then I asked other colleagues, but no one encountered a similar situation. It was very embarrassing. I solved it at noon, and then I found the reason for a long time in the afternoon. Now I simply do it. Go back and do a comparison test with a few ideas.

  • 1. Why does this happen?
    It should be that I didn't pay attention when I clicked. I clicked on the method and set a breakpoint to cause this situation, and the reason why this problem did not occur on the mac is also clear, because there is no method breakpoint on the mac.

  • 2. Is the problem of Method Breakpoints related to the system?
    After solving this problem on Windows, I have this idea in my head. Will the problem of Method Breakpoints appear on both Windows and Mac? The answer is yes, once there is a method breakpoint, it will be stuck.

  • 3. Does the problem of Method Breakpoints only appear in interface methods?
    Because the breakpoint of the problem is on the interface method, so I have this idea, and I got the answer after verification, and this problem will also occur when the breakpoint is on the implementation class.

Through the verification of these problems, I have also made this problem clearer. It is a definite fact that Method Breakpoints will slow down debugging. It has little to do with the operating system, and it has nothing to do with whether it is a class method. Then Why is this so?

Why does the breakpoint on the method do this?

Generally, if you encounter this kind of problem, you will first check it on the Internet to see if a friend has sorted out the answer, but there is no such problem. You can only check it a little by yourself. In the official document of idea, IntelliJ IDEA Help , there is such a thing. A description:

method-breakpoint-doc

Note this sentence:

Note that using method breakpoints can slow down the application you are debugging.

Using method breakpoints can slow down the program being debugged.

Summarize

In response to this, I also make a suggestion to friends who use IDEA: use method breakpoints less, and try not to hit too many breakpoints in the project. Just hit it wherever you debug, and just remove it after debugging.

So far, the cause, process, and result of the incident have been roughly introduced. As for the last answer, I don’t think I am particularly satisfied. The official document just said that this approach will slow down debugging, but the reason is deeper. In other words, the principle still needs to be studied and studied, and now I am still looking for an answer that I am satisfied with. If I find it, I will organize another article to share it.

First published on my personal blog , thank you for your support.

end

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325817326&siteId=291194637