Running a program in Debug mode is incredible slow - java

Since recently it's much slower running a program in Debug mode in Eclipse Galileo.
I'm not aware of any changes.
Do you know what could be the cause? Running it normally is not a problem.

Another "debugging break" is the use of method entry/exit breakpoints.
Did you try to remove all breakpoint definitions once?
Sometimes i think Eclipse is getting out of synch with some of its internal/displayed state. Perhaps you should try to setup a new (not copy) of your workspace. This sometimes helps me to recover from spurious features.
This is how you can remove all breakPoints
Eclipse -> Run -> Remove All Breakpoints - for removing all Breakpoints for all Time
Eclipse -> Run -> Skip All Breakpoints - for temporary remove breakpoints

I faced this issue lot of time. Solution is simple, Remove all breakpoints.
(Run >> Remove All Breakpoints)

I was just running a program in Eclipse debug mode that was almost instant without debugging but when I ran it in debug mode, it was really slow. I went through and deleted a ton of random useless breakpoints I wasn't using and then the program sped up A LOT (200x or so).

Disable 'Show method result after a step operation'.

I have found that i often forget that i have a bunch of expressions added to the expressions panel that are no longer needed that are none the less being evaluated (or are failing to evaluate) and this slows stuff down a good deal. Make sure that you keep those expressions cleared out when not needed.

Close eclipse... clear %temp% folder, temp folder... disable breakpoints... in most cases this will definitely solve the problem.

What kind of JVM are you attaching to? I found in my experience, that in debug mode IBM JDK is slow like hell.
For all JVMs, check if you have conditional breakpoints with expensive condition. Try disable breakpoints. You may have exception breakpoints or expressions. Try disable or remove them.

In my case, Eclipse was trying to build files, which I was doing manually.
Going to Window -> Preferences -> Run/Debug -> Launching, and then disabling "Build (if required) before Launching" underneath General Options solved the slowness.

Clearing temp files on Windows fixed it for me
"C:\\Documents and Settings\\{user}\\Local Settings\\Temp"

Normally Java Virtual Machine turns off Just in time compiler (JIT) when running in debug mode. On IBM WebSphere, the IBM JDK is heavy de-optimized and will be very slow.
By the way debugging also make impossible to recompile and optimize the code.
Relay on logging for complex debugging: it will save your days on production, where you cannot debug for sure.

With all the learning over the years working with eclipse, here are couple of suggestions
keep your open projects to minimal what you actually need
keep it lean and thin - uninstall the plugins/features which you don't use (mylnn, validations etc).
No matter what you do, the eclipse tend to get slower over the time. The ultimate solution to get a responsive IDE is to recycle your existing workspace (create new workspace and bring in the projects which you need).

Before you run your application in debug mode press on (disable all breakpoints) and you wont experience slow loading or any problems. After your application has started just enable the breakpoints and then you can debug your code.

I faced this issue recently after upgrading my macOS version.
I wasn't able to fix the slow debugger with all the above solutions, I ended up installing a newer version of eclipse, and everything works prefect after that.

It happened to me once and the problem was, I had the folder with ALL my projects source code in the Source Look-up. This way, not only the debugger got really slow (because it probably crawled all my files) but also I could not do a lot of things such as inline execution.
The takeaway: check your Source Look-up. When debugging right-click in any thread from the Debug view, choose Edit Source Look-up and see what what you can/should remove from there. In my case, it was a spurious folder, other times you may have too many projects, folders, JARs etc. and may remove some.

Recently i was having extreme slow performance debug, both in eclipse and visual studio code (vs code)
In my case, the problem was with lombok configuration in JPA entities.
I changed the #Data anottation to #Getters and #Setters.
Looks like hashCode() and equals() implementantion of lombok was in conflict with JPA.

I've had the same problem. The work around i'm using is to just set a single break point and run to it. After that I don't try to step over or continue i just restart the test and move my break point to the next line I want to view. I am using JUnit with Mockito in Intellij. I'm guessing it has something to do with the byte code manipulation not matching the actual code in intellij. (In intellij, there is an implementation internal to intellij for running JUnit tests. Mockito may not play will with it)

Related

IntelliJ IDEA: Integrated Maven builds often delayed

When triggering Maven lifecycle entries in IntelliJ IDEA (clean+install for example), the IDE launches the associated Java with plexus-classworlds-<version>.jar from the associated Maven installation.
Sometimes (mostly) the Java launch takes up to 2 minutes before the Maven action starts.
Any thoughts what could cause this? I'd like to use this integrated feature instead of Maven command line calls (which work "normal" regarding no delay).
Network related Java problems might be, I'm inside Intranet, Firewall, custom proxy.
There is no status or logmessage regarding the Java launch except for the time indicator in the run window.
Problem - well - "solved" by adding java as an exlusion for the av scanner (avira).

Remove unnecessary Java casting in Eclipse/STS does not work?

I am using STS 3.1.0 IDE and would like to write some basic Java test programs to practice object up/downcasting principles
I noticed that the IDE is automatically removing unnecessary castings, which I don't want at this point for practicing purposes, so I figured out that it should be possible to deactivate this feature, like e.g. described in this thread: Remove redundant casts in Java
I made a copy from the "Eclipse [built-in]" clean-up profile which was used by the IDE by default, unticked the "Remove unnecessary casts" checkbox, and set this copied profile active for the particular Java project. Nonetheless the IDE still keeps removing the casts. IDE restart/logout/computer restart do not seem to help either
Maybe it is some very basic issue, but I ran out of ideas so thought to post it in here. Any help is appreciated
Seems to have found the answer. Apparently it is not only possible to define the handling of unnecessary casts under Properties -> Java code Style -> Clean Up, but also under Properties -> Java Editor -> Save Actions. After I unticked the concerning checkbox here as well, the castings were not removed any more

How I can find all unused import programmatically?

In my case there are two reason for doing that:
Sometimes people by mistake import classes which present in macbooks JDKs but absent in Linux. That causes build to fail on ci servers which are Linux based boxes. I doesn’t happen frequently, but when it does happened I'm thinking that there should be some smarter way to find out that earlier.
Unused imports trigger warning in IDE/code analysis. From time to time somebody need to spend time on cleaning up this stuff. Even if its just single right click in IDE you still need to commit your changes and make sure everything alright on build.
I'm curious if there is any way to find unused imports programmatically (lets say from unit test) and fail locally if there are any.
Maybe failing a build because of unused import sounds harsh, but if it saves time for team overall it makes sens to do so (would love to hear opinion on that as well).
UPDATE:
I followed yegor256 suggestion and incorporated Checkstyle task with initially small subset of Sun Code Conventions (unused imports is one of them) and made it break a build if violations found.
After one week of trial we've got zero unused imports in our codebase and surprisingly zero complaints about this rule (by the way, Checkstyle is really fast: analyzing ~100KLoc taking less than one second).
As for using IDE for such analysis: yes, it good choice, but having this kind of checks run as part of automated build is better.
What you're trying to do is called static code analysis. Checkstyle can help you. If you're using Maven, this plugin will do the automation for you: http://maven.apache.org/plugins/maven-checkstyle-plugin/
You can also take a look at qulice.com (I'm one of its developers), which integrates a few static analysis tools and pre-configures them (incl. Checkstyle, PMD, FindBugs).
If you are using eclipse IDE or IntelliJ IDEA, you can configure them to
1a. organize imports / remove unused imports on save or before commit (see cleanup preferences)
1b. switch the "unused imports" warning to an error (see error settings)
2a. configure a jre which does not include com.* stuff
2b. configure the warning of proprietary api usage from the jre to be an error
You might still want to check that on the build server, though. In this case the more complicated stuff like configuring CheckStyle would still be necessary.
I'm curious if there is any way to find unused imports programmatically (lets say from unit test) and fail build locally if there are any.
I use IntelliJ to organise imports, this removes all the unused imports. You can do this with one hot key from the top of you code base to correct all the imports. (It also has over 700 other types of static checks and fixes)
Maybe failing a build because of unused import sounds harsh, but if it saves time for team overall it makes sens to do so (would love to hear opinion on that as well).
I have IntelliJ check in code which formatted and with imports organised so the issue never arises in the first place. ;)
In Computer Science the name given to such a process of analyzing the code without executing is known as static code analysis.
Try using an IDE, I am using Eclipse, which marks all the Unused imports and Unused Variables or methods in with a Yellow color underline....
Aren't these unrelated questions? If you import classes only present in the local JDK, these imports are used (just unsatisfied). For either problem, I recommend solving it in the IDE so the problem will be detected when code is written, rather than prior to checkin (the earlier the detection, the easier the fix ...).
In eclipse, you could prevent unsatisfied imports with access rules, and automatically fix imports whenever a source file is saved by enabling the appropriate save action. If you check these settings into version control, you can easily share them with the team.
I see lot of comments in same way that use this IDE or that IDE. But all my friends try to understand the difference. Doing something programmatically is different and using IDE is different.
If I want a process to be programmatic then suggestion of IDE is not useful. It might be possible some one is asking this question because he is building complete process and this step is part of it. How opening IDE would help him on different machines and OS where CI is working?
I too building one tool on similar lines. I achieved it up to some level but it programmatically open IDE and close it automatically and fixes source code too. But opening same in Linux might be a question for me.
Understanding some one's view before answering is really very important.

Prevent commiting files to SVN with warnings using eclipse

I have a big Java project with thousands of compilation warnings. I would like to find a way to prevent developers commiting files with warnings, so gradually all warnings would disappear. If I commit a file with compilation error Eclipse displays an error message, but I couldnt find any way to do the same with warnings. The closest thing I found was The Commit warning checker http://commitwarncheck.sourceforge.net/ but that is not really integrated into the commit process, it just provides a view. Is there any better solution?
I see 2 options. First, at least with Subclipse, there's an Eclipse preference for this: Window / Preferences / Team / SVN / "Commit resources with warnings". There's one for "errors" as well. Both can be set to "Yes", "No", or "Prompt". However, this will require you to make sure that your entire team keeps these options set as you'd expect - as well as making sure that they have all of the other Eclipse preferences set to generate the same errors / warnings.
Using Subclipse 1.6.18:
Another option is to make use of SVN commit hooks, essentially the beginnings of a Continuous Integration (CI) process. You could actually check for a limited set of things, and allow/deny the commit at that time, but I'd start worrying about commit performance. A better option might be a true CI process that runs a build (either scheduled, or potentially even per-commit) - and emails or otherwise alerts the developer if an issue is detected.
The complication with this later option is repeating the Eclipse build - including detection of all Eclipse-configured errors and warnings - in a scripted manner. (If anyone finds a great way of doing this, please let me know! Eclipse provides a scriptable option for using its code formatter, but I've not seen a similar option for checking for errors / warnings using the checks provided by Eclipse.)
Otherwise, you'll probably be better off starting to migrate over to tools such as Checkstyle and FindBugs that work equally well both inside and outside of Eclipse. (However, relating back to my own interest above, I've not found any combination of a few tools - including these - that can at least match the same checks that Eclipse provides.) Combine this with Maven / m2e, providing a common build configuration / process that can be shared by both Eclipse and your CI system, and you should be in good shape.

How do I tell a remote debugger to actually suspend at some point?

I'm using IntelliJ Idea debugger and I have some 3rd party app with its sources (shouldn't matter, but it's hyperic). I need to see when some methods are being executed and trace the execution process. I've successfully connected to the app using remote application debug but can't figure what to do next. O_o
It is possible to suspend the app, but how to attach sources and tell it when exactly to suspend (method call/line of code/etc)?
EDIT: Alternatively I could use eclipse (doesn't matter what to use if it's working).
EDIT2: It's not one of my projects/modules/whatever.
Open the source code in an editor and set a break point.
The debugger should be smart enough to figure out what you want to achieve.
[EDIT] Create a small project which contains the sources and all the JARs. That should compile without error and allow you set breakpoints.
In Eclipse, you can attach sources to JARs. That way, you can set breakpoints.
To debug the remote application you need it's sources in your eclipse (whatever IDE) project. And then just set breakpoints and launch remote debugger with appropriate port.
Is it possible that the source code is out of sync with the code being executed? I've had this happen before so that the breakpoint I set was actually on a non-executable line (whitespace, comment) according to the remote machine's version of code.
The only other time I've seen something like that was when the remote machine was running several JVMs and I accidentally connected to the wrong port (and thus the wrong JVM).
When you are debugging the red dot that represents the breakpoint should change slightly, what does it look like while you are debugging? For example, if the line is non-executable I think there will be an X on top of the dot.

Categories

Resources