How to boost Eclipse and Glassfish speed to development? - eclipse

Recently I bought a good computer with processor i5 3570k and 16GB of RAM, I wonder if there's a way to increase my Eclipse and Glassfish speed, to they can work together to startup and do the hot deploy while I'm developing my applications.
This is my eclipse.ini
-nosplash
-vmargs
-Xincgc
-Xss500k
-Dosgi.requiredJavaVersion=1.6
-Xms512m
-Xmx1024m
-XX:NewSize=8m
-XX:PermSize=1024m
-XX:MaxPermSize=1024m
-XX:MaxPermHeapExpansion=10m
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=70
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseParNewGC
-XX:+CMSConcurrentMTEnabled
-XX:ConcGCThreads=2
-XX:ParallelGCThreads=2
-XX:+CMSIncrementalPacing
-XX:CMSIncrementalDutyCycleMin=0
-XX:CMSIncrementalDutyCycle=5
-XX:GCTimeRatio=49
-XX:MaxGCPauseMillis=20
-XX:GCPauseIntervalMillis=1000
-XX:+UseCMSCompactAtFullCollection
-XX:+CMSClassUnloadingEnabled
-XX:+DoEscapeAnalysis
-XX:+UseCompressedOops
-XX:+AggressiveOpts
-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses
Any recommendations about it ?

Eclipse and Glassfish are just containers, their tuning depends heavily on how you use them (number of projects in eclipse, number of apps in glassfish, ...). However, I see some weird JVM options in your eclipse.ini. Here are the ones I would simply remove :
-Xincgc means -XX:+UseConcMarkSweepGC which is a low pause GC that implies a high overhead compared to parallel collectors. I would switch to parallel collectors.
-XX:NewSize=8m means that the young generation size is 8MB, this is really small and against the weak generational hypothesis. Remove this option and let the JVM adjust heap size depending on how you use the application.
-XX:PermSize=1024m is equal to MaxPermSize. Setting min=max is a nonsense. Remove the minimum size and let the JVM manage permanent generation size.
-XX:+UseConcMarkSweepGC, cf 1.
-XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSConcurrentMTEnabled -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:ConcGCThreads=2 -XX:CMSIncrementalDutyCycle=5 -XX:+UseCMSCompactAtFullCollection -XX:+CMSClassUnloadingEnabled -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses are CMS related. Cf 1, I would switch to parallel collectors so you should get rid of those options.
-XX:+UseParNewGC -XX:ParallelGCThreads=2 means that you were giving 2 threads for a parallel collector in the young generation (8 MB). This won't really do anything.
-XX:GCTimeRatio=49 -XX:MaxGCPauseMillis=20 -XX:GCPauseIntervalMillis=1000 here you are saying "I want my GC to take les than 49% of my time, with a pause of maximum 20ms and at least 1 second between each pause". You are asking for very short GC that will happen very often. Probably not what you want.
You may notice that these are almost all your JVM options. This is correct :)
Try this configuration and let us know if it solved your problem :
-nosplash
-vmargs
-Xss500k
-Dosgi.requiredJavaVersion=1.6
-Xms128m
-Xmx1024m
-XX:MaxPermSize=1024m
-XX:+UseParallelGC
-XX:+UseParallelOldGC
-XX:+DoEscapeAnalysis
-XX:+UseCompressedOops
-XX:+AggressiveOpts
-Xloggc:gc.log
-XX:+PrintGCDetails
Sources :
http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html
http://jvm-options.tech.xebia.fr/

Do you have an SSD? If not buying one will really improve your performance experience because development means a lot of IO.

If you want to speed up your development process, i think you are looking at the wrong place.
The performance of your system should be more than enough. Maybe you could raise the -Xmx a bit, depending on your application. Maybe an ssd would boost the performance too.
I for myself, could speed up my development with jrebel(http://zeroturnaround.com/software/jrebel/). This is a tool that allow you hot replacement of nearly any part of your application. So you do not have to redeploy the whole application every time. I know it costs money, but it paid of quickly. Maybe there are also some free alternatives i don't know yet.

win/linux/mac: you can put JDK into read-only RAM disk and run it from there
linux: you could use anything-sync-daemon to keep both Eclipse and Glassfish (and possibly maven local repository ".m2") in RAM and synchronize it into HDD/SSD periodically
I also recommend reading this:
Tip 1 : Always run the latest JDK and Eclipse.
Tip 2 : Tune Eclipse Preferences
Tip 3 : Keep your JDK on a RAM Disk
Tip 4 : Tweak your eclipse.ini
Tip 5: Get your anti-virus outta here
Tip 6: Keep SVN and GIT out of Eclipse
Tip 7: Use your keyboard
at http://www.nicolasbize.com/blog/7-tips-to-speed-up-eclipse/

Related

resolve java.lang.OutOfMemoryError: Java heap space in NetBeans

Currently I am using NetBeans-8.1 in 32-bit Windows 10. I'm getting the following error:
java.lang.OutOfMemoryError: Java heap space.
I already changed the memory size to -Xmx1024m in netbeans.conf file, added environment variables -Xms1024m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=256m but still getting same error. Are there any problems with NetBeans on 32-bit operating systems? My system has 4GB of RAM.
Make sure that you have correctly set the flags for NetBeans, otherwise it will not be recognized: NetBeans requires the -J prefix for arguments to the JVM.
So you need to use
-J-Xms1024m -J-Xmx1024m
Also you should be aware that Oracle states that Windows 32 bit is capable only of about 1.4GB - 1.6GB of heap. See http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_heap_32bit
You should increase the -Xmx value, which is the maximum amount of memory the JVM can allocate for the heap. See this answer for details about the flags.
For example, you could use -Xmx4G to allow it to use up to 4GB of memory on your system.

constant eclipse crashes

I am using the latest eclipse version (Indigo) on a machine: CPU: Intel Core i5 2.4 GHz, 8 GB RAM, 64-bit Windows, and eclipse keeps freezing very frequently. I increased all the memory things (permgen ...), but it did not help. When it stops responding a window pops out with the following data:
Java was started but returned exit code= -805306369
-XX:PermSize=256M
-XX:MaxPermSize = 512M
-Xms512m
-Xmx1024m
...
If you need more input, please feel free to ask :)
Any help would be very appreciated. Thank you, in advance.
Looking at your 64 bit Windows; I remembered this thread. See if the solution there resolves it
https://superuser.com/questions/314015/eclipse-crashed
Also as my comments above suggests; a -clean start to eclipse is a good idea, as you have good enough RAM to get it cleaned faster. Slower machines will struggle cleaning every time you start eclipse.
Run eclipse with -clearPersistedState from terminal/command prompt

DartEditor.exe and java exit code 1

I try to run DartEditor on Windows. I've downloaded the latest version from:
dartlang.org/docs/getting-started/editor/index-win.html
(i tried both the stable and untested latest version - same results)
At first Editor was facing problem with finding the java virtual machine, so I added the path to the "DartEditor.ini", which now looks like that:
-data
workspace
-vm
C:\Program Files\Java\jdk1.7.0_02\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms40m
-Xmx1024m
Now java is starting BUT it's returning following error:
(sorry for URLs, but i'm not yet allowed to post images)
and information:
I suppose that this error is connected with eclipse, but sadly I have no idea where exactly the problem is. Any help appreciated.
I don't see anything wrong with your posted .ini contents, it could be that you are seeing https://bugs.eclipse.org/bugs/show_bug.cgi?id=188968
Essentially the -Xmx1024m might be too large and the jvm can't find a contiguous block of memory that large. Shared libraries might be loaded in the middle of the address space fragmentin the available memory).
By removing the .ini file, you get the default Xmx args which are much lower. You could try changing to -Xmx512m or -Xmx768m.
I had the same issue until I upgraded my JRE from version 6 to 7. Though dartlang.org states that Dart Editor's minimum required Java version is 6, I believe they may have forgotten to update this info.
Additionally, dartlang.org states that Windows XP is not supported. FYI

Eclipse memory restricting

I am using a 32bit WinXP with no upgrade in sight, is there a way to limit how much memory Eclipse allocates throughout the day? I am also running Weblogic 10 server in debug mode inside eclipse. After a few hours I have an 700mb STS.exe (eclipse) and 400mb java.exe (server). Is there at least a way to force a GC on eclipse?
Here are the settings i surrently use, which seem to me are not being observed.
-vm
C:\bea\jdk160_05\bin\javaw.exe
-showsplash
--launcher.XXMaxPermSize
128M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m -Xmx512m
-Dsun.lang.ClassLoader.allowArraySyntax=true
EDIT: here's the monster of a project: Eclipse and Firefox 4.
is there a way to limit how much memory Eclipse allocates throughout the day?
The values of -Xmx and -XX:MaxPermSize place an upper bound on the memory that the JVM will use.
Is there at least a way to force a GC on eclipse?
AFAIK, no. Even if there was, it probably wouldn't help. The JVM is unlikely to give the memory back to the operating system.
Here are the settings i currently use, which seem to me are not being observed.
Based on what you've said (memory usage 700Mb for eclipse.exe), I'd say the settings ARE being observed.
What can you do to get Eclipse to use less memory?
Trim the values of -Xmx and -XX:MaxPermSize. However, if you do this too much you are liable to make Eclipse sluggish ('cos it has to GC more frequently) and ultimately flakey ('cos it will run out of memory and things will start failing with OOMEs)
Get rid of superfluous plugins.
Switch to a "smaller" Eclipse (e.g. the "Classic" distro) ... though you'll lose some of the J2EE support that you are probably using.
Close projects.
Close files.
Restart Eclipse more often.
But the best solution is to upgrade your platform:
Buy some more memory for your PC / laptop. You can probably max it out for a couple of hundred dollars. It is worth it.
Switch the OS to Linux. In my experience, Linux is a much better platform for doing Java software development than Windows XP. It seems to do a much better job in terms of both memory and file system management. The performance difference on identical hardware is significant.
You can always set up your machine to dual boot, so that you can still run XP for other things.
The 700MB of OS level process usuage is consistent with your memory settings. Take 512m for heap + 128m for permgen space + a bit of overhead for the JVM itself.
You cannot force GC. If memory was releasable, JVM would release it. Note that you cannot simply look at OS level process usage as that represents the point where the JVM memory usage peaked. JVM never releases heap or permgen space once it expands to a certain size. It is simply too expensive and not really necessary. The allocated space is in virtual address space of the JVM process. It doesn't represent actual physical memory usage. As physical memory gets tight, the OS will agressively swap out to disk memory pages that haven't been used recently.
So... You need specialized memory analysis tools to get accurate representation of Eclipse memory usage.
If you are seeing a lot of disk activity when there shouldn't be any, the OS may be indeed out of physical memory and doing a lot of swapping. Try closing a few projects or restarting Eclipse. It only takes one plugin with a memory leak to consume all of your available memory.
I'm assuming that you are running BEA JRockit judging by the path to javaw.exe. Note that the -X... options are JVM-specific, so they may not work the same way for JRockit as in Sun's JVM. This link seems to indicate that you should be using
... -Xms:40m -Xmx:512m ...
But setting a heap size limit will only cause Eclipse to fail once it reaches the limit, so you won't solve the real problem. Forcing a GC usually doesn't help; any sane VM will GC periodically or when needed.
Having a 700Mb Eclipse sounds like your Eclipse is either processing large amounts of data, or it is leaking memory. JRockit seems to have a memory leak detector which may be able to give you a hint of where the problem lies.
The ini file memory settings won't help for the Virtual machine. Change VM arguments, as here
Eclipse is very thirsty. Limiting it is most likely to crash it. You really need a new computer.

How to reduce Eclipse's memory usage?

The memory usage of Eclipse 3.4 is through the roof to the point where it's becoming an issue.
I have a simple BlackBerry project loaded and the usage skyrockets to nearly 400 MB, sometimes higher. Is there something that can be done to bring it down?
Eclipse 3.4 can consume a lot more memory than the previous versions, courtesy the spellchecker plug-in.
You can switch off the plug-in by going to Window -> Preferences -> General -> Editors -> Text Editors -> Spelling, and unchecking the box title 'Enable spell checking'.
Of course, the tips offered to use larger heap sizes and better garbage collectors would do you good as well.
Checking General -> Show heap status will enable this
in the bottom bar.
This way you can manually run the garbage collector whenever you want by clicking on the trash can. It's not a fix, more like a workaround, but it helped reduce massively my RAM / CPU usage.
Remove +UseG1GC option from eclipse.ini. I've read from here that It is only used for araound 6GB heap memory.
In Eclipse Luna 4.4.1
Was trying to cut my memory usage in Eclipse. I managed to shave mine from 600mb to 300mb. I did the following:
Turned off the plugins activated on startup that I wasn't using. Windows > Preferences > General > Startup and Shutdown
Closed projects I wasn't working on at the time.
Found the hints/tips here : http://blog.elijaa.org/2010/09/20/tricks-to-speed-up-eclipse-php-helios-pdt-2-2/
Modern versions of Eclipse do need quite a bit of RAM to do their thing. But should still run pretty fast on any modern machine.
Assuming you have enough physical memory (2GB is fine unless you have lots of other processes running, or you're using RAD), see this article on Eclipse's memory usage for some tips on tweaking the settings. The two most common culprits are Xmx and/or MaxPermSize being set too low (Xmx defaults to 256M and MaxPermSize defaults to 64M).
You modify the values by passing command line arguments or tweaking the eclipse.ini in the Eclipse install location.
You should end up with something like this:
...
-vmargs
-Xms128m
-Xmx1024m
-XX:MaxPermSize=128m
While you probably could tinker with the configuration, removing various plugins etc, it's likely to be more cost effective to buy more memory. How much do you currently have? I would consider a developer machine with less than 2GB of memory to be under spec, and I suspect many people would double that...
My Eclipse is taking over 800MB resident, and 2GB virtual (part of it swapped out perhaps).
Java can be a hog, it's giving Java bad press all the time.
However, there is a little something that many people don't know: the incremental garbage collector. -Xincgc
The side effect is that it hands memory back to the system from time to time.
By default Java just takes and takes, and when it doesn't need memory anymore, it keeps it for itself.
The incgc is a different strategy where it becomes more reasonable to assume that memory can be handed back the system without running into trouble.
This can however affect performance.
There are many garbage collection settings. You can also have multiple threads handle GC. The parallel GC does that. Not sure if that one hands memory back, don't think so.
If 400 Mb of RAM is a big issue for you, you might want to try another IDE. Eclipse stores a lot of state information, some or most of which you don't actually need. That's a design choice.
Right now, I have the same project open in both Eclipse and QtCreator: after a clean rebuild, Eclipse uses 156 Mb RAM, Qt Creator is happy with 66 Mb.
You can try the 64bit version of Eclipse with the 64bit version of JDK on Windows 7. Those both caused some odd issues with the 3rd party Framework I have to work with. The 32-bit of JRockit (free now) from Oracle seems to be faster and be a little better on memory. This is my Eclipse.ini settings:
This is my eclipse inn
-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
-nosplash
org.eclipse.platform
--launcher.XXPermSize
512m
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vm
C:/Program Files (x86)/Java/jrockit-jdk1.6.0_31-R28.2.3-4.1.0/jre/bin
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xquickstart
-XX:+AggressiveHeap
-XX:+AggressiveOpts
-XX:+UseParallelOldGC
-XX:ParallelGCThreads=2
-XX:ThreadPriorityPolicy=1
-Xverify:none
-Xms1100m
-Xmx1100m
I switched to the 32 bit JRockit JDK which seems a little faster for Eclipse. I turn off and don't install more than I need. For each separate type of app development (Android, J2EE, just Spring, ...) I have different Eclipse installations. Hard drive space is cheap. Then I can have just the plugins I need for each one. I would never want all the Android tools loading if I wasn't using them. STS is also good for just the Spring stuff and I have one just for OpenShift Cloud work.
Try disabling your eclipse plugins. Eclipse was hogging half of my of my memory when I had the saros plugin open.