The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
Replies:
37 -
Pages:
3
[
123
| Next
]
Threads:
[
Previous
|
Next
]
Many Eclipse users have adjusted their VM heap size when launching
Eclipse by way of the
-vmargs
-Xmx256m
argument. Some have done it to avoid
OutOfMemoryException
s, to tweak
performance or just as good preventative measure for larger installs.
However, most users have never worried before about the size of their
VM's
permSpace
or even had a
reason to care, this article will hopefully shed some light on
situations when you should care and how to weak your heap and perm
settings to get some performance gains in Eclipse.
Combating OutOfMemoryExceptions
A majority of
OutOfMemoryException
s
when using Eclipse are caused by too little heap space for your VM. In
this case the old wisdom of adjusting your maximum heap space with
something like
-vmargs -Xmx256m
is still good advice; giving your Java apps more space to run in always
helps performance. However, there are situations where even with an
enourmous heap size you can still end up with
OutOfMemoryException
s in your
workbench. The reason for this is that your VM is not running out of
heap space, but is instead running out of what is known as
permSpace
. The VM's
permSpace
is the area of the VM
that is used to store data structures and class information (not
instances, but the class definitions themselves). In the case of a
large enough Java application that may contain 10s of thousands of
class files that must be loaded you start to see how the VM can
physically run out of space storing all of that information into the
default
permSpace
. If you
have run into a situation where you have run out of
permSpace
you will want to adjust
your Eclipse shortcut,
eclipse.ini
,
or startup script to include the argument
-XX:MaxPermSize=64m
; generally
speaking the more memory you give the VM, the more performant it will
be. Tuning this value can help you find what works best for your
Eclipse install.
Improving Performance
Now let's assume that you are not encountering any exceptions and
Eclipse is running just fine, but you would like to improve the
performance. I have found 2 rules of thumb when tweaking the heap size
and
permSize
for Eclipse to
maximize performance, and that is to 1) give the VM as much ram as you
can spare and 2) set your
min
and
max
values to the same
amounts to avoid resizing. While neither of these guidelines are
revolutionary I have found using them both to really help improve
performance; in the case of MyEclipse 4.0.3 on Eclipse 3.1 my
subjective perception of the performance increase is anywhere from 50%
to a 100% increase on my machine (your mileage may varry depending on
hardware, current arguments, etc).
For a machine with 512MB of ram with the developer mainly using just
Eclipse (any maybe a browser and IM) I would suggest the following
arguments:
-vmargs -Xms256m -Xmx256m
-XX:PermSize=64m -XX:MaxPermSize=64m
For a machine with 1024MB of ram with the similar run case as
described above I would suggest:
-vmargs
-Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m
and for machines with anymore ram than what I outlined above, adjust
to fit your preferences. I have 4GB of ram in my machine and use a heap
size of 1024m and a
permSize
of 512m. You may need to go through a few test runs with different
settings to find which one works best for your computer. You may find
that only using 256m heap space is sufficient while you end up needing
to increase your
permSize
to
128m. I'll leave it up to you to decide.
Conclusion
I hope some of you have found this tip handy. I know adjusting
memory arguments is a topic that has been discussed to death since the
dawn of Java, but I also know the vast majority of Eclipse users I help
have no idea how to adjust the command line arguments that Eclipse uses
nor do they understand why they would adjust them. This tip is also
intended for folks that were never aware of the
permSize
arguments and what they
can do for runtime performance as well as avoiding mysterious
OutOfMemoryException
s that make no
sense.
I would encourage you all to share your own performance tweaks in
your responses as I may have missed some really good arguments here
that have helped you see some noticable improvements in performance or
reliability. Thanks for reading.
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Thanks for the tip. I already use the -Xms and -Xmx parms, but I don't generally spend alot of time adjusting these parameters. Is there a reason why you tend suggest setting the size and max sizes set to the same value, for instance, -XX:PermSize=128m -XX:MaxPermSize=128m rather than something like -XX:PermSize=64m -XX:MaxPermSize=128m? (same for the -Xms and -Xmx parms).
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
I think (as far as Eclipse is concerned), there's another switch: (-Dide.gc=true) which can also affect runtime performance. I am not sure how this affects it - but remember reading about it in some newsgroup.
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Mike,
I'm not a VM expert, but my reasoning behind it is similar to the reasoning behind setting your Windows swap to have the same min/max; it's to avoid the cost of resizing the addressable space. I have no hard numbers to indicates this help, just something I thought 'made sense'.
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
i don't know for windows, but on linux it is better set
lesser initial pool (-Xms) - you needn't max space , maybe and heap can increase - when eclipse spawn new process, then
this proccess have lesser initial pool and it work better
i think that is same on windows except winodw have any really bad swaping
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Periodically, if Eclipse isn't doing anything (the user's not typing, there aren't any background jobs etc.) it calls System.gc() to request (rather than force) a garbage collection. Given the amount of objects (and arrays) that are transiently created during Eclipse's normal operation, it certainly helps clean these up.
It's also why in Eclipse 3.1, the memory utilisation goes down after you stop using something; before, it would grow and grow and grow. For example, if you load a JSP in WTP, it needs to load a bunch of classes to deal with the JSP. If you close it, it doesn't need all of them any more and so they become eligible for garbage collection. Some VMs are intelligent and now release memory back to the OS, but they tend only to do so if you've requested a System.gc().
By the way, there's a horrible bug in Java 1.5 or Java 5 or JSE5 or whatever they're calling it these days (JavaBook Pro, anyone?) that causes System.gc() to max out and take the highest priority possible for doing System.gc() runs, which can temporarily interrupt processes on a single processor box. I gather that the bug has been fixed and is either in the latest (or upcoming) version.
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
i agree that it can help, but no too much on linux
linux memory managment is smart and unused memory swap to disk - you need enough swap (or memory) only
maximum swpa space is more important for linux
i don't sure for windows, but modern OS must have modern swapping
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Yes I believe so since it is based on Eclipse. If the version of WSAD you are using is based on Eclipse 2.x, there is no .ini file and you need to specify the command line arguments directly in your shortcut or script you use to start WSAD.
Clemens,
I thought a lot of work between the GTK/Pango and SWT team took place about a year ago to boost performance. Is this still not the case with the 3.1.1 or 3.2 releases?
> what is your system (hardware) and what mean slow -
> do you use visual editor, maybe ?
My system is a P4-2.6ghz with a Nvidia GeForce 488Go.
Anything which has to do with UI performance is slow like:
* View resizing
* window resizing
* menu-performance (though a lot better now with composite)
* scrolling complex text fast
For now my laptop dies do I work with my Athlon800 which is dual-boot. On windows Eclipse's ui is really fast and useable but obn Linux its nightmare. And my development-enviroment is linux
> I thought a lot of work between the GTK/Pango and SWT
> team took place about a year ago to boost
> performance. Is this still not the case with the
> 3.1.1 or 3.2 releases?
I currently use 3.1.1 but I only saw very small improvements between releases.
Motif of the fox port of SWT perform so well, is it really so hard to do the same with GTK2?
So either a concept of any involved libraries is broken or something else does not work right.
I don't know nore do I care - I know that these issues will not get fixed in near future havin a look at the performance bug at eclipse. I think it has the 2. most votes but the devs officially explained that they do not see the need nore are they willing to improve the GTK2 port further.
btw. netbeans runs a bit slow on my Athlon800 under Windows and Linux but performs superior un my P4-2.6ghz laptop.
Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
At 12:35 AM on Jan 16, 2006, Riyad Kalla
wrote:
Many Eclipse users have adjusted their VM heap size when launching Eclipse by way of the -vmargs -Xmx256m argument. Some have done it to avoid OutOfMemoryException s, to tweak performance or just as good preventative measure for larger installs. However, most users have never worried before about the size of their VM's permSpace or even had a reason to care, this article will hopefully shed some light on situations when you should care and how to weak your heap and perm settings to get some performance gains in Eclipse.
Combating OutOfMemoryExceptions
A majority of OutOfMemoryException s when using Eclipse are caused by too little heap space for your VM. In this case the old wisdom of adjusting your maximum heap space with something like -vmargs -Xmx256m is still good advice; giving your Java apps more space to run in always helps performance. However, there are situations where even with an enourmous heap size you can still end up with OutOfMemoryException s in your workbench. The reason for this is that your VM is not running out of heap space, but is instead running out of what is known as permSpace . The VM's permSpace is the area of the VM that is used to store data structures and class information (not instances, but the class definitions themselves). In the case of a large enough Java application that may contain 10s of thousands of class files that must be loaded you start to see how the VM can physically run out of space storing all of that information into the default permSpace . If you have run into a situation where you have run out of permSpace you will want to adjust your Eclipse shortcut, eclipse.ini , or startup script to include the argument -XX:MaxPermSize=64m ; generally speaking the more memory you give the VM, the more performant it will be. Tuning this value can help you find what works best for your Eclipse install.
Improving Performance
Now let's assume that you are not encountering any exceptions and Eclipse is running just fine, but you would like to improve the performance. I have found 2 rules of thumb when tweaking the heap size and permSize for Eclipse to maximize performance, and that is to 1) give the VM as much ram as you can spare and 2) set your min and max values to the same amounts to avoid resizing. While neither of these guidelines are revolutionary I have found using them both to really help improve performance; in the case of MyEclipse 4.0.3 on Eclipse 3.1 my subjective perception of the performance increase is anywhere from 50% to a 100% increase on my machine (your mileage may varry depending on hardware, current arguments, etc).
For a machine with 512MB of ram with the developer mainly using just Eclipse (any maybe a browser and IM) I would suggest the following arguments: -vmargs -Xms256m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=64m
For a machine with 1024MB of ram with the similar run case as described above I would suggest: -vmargs -Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m
and for machines with anymore ram than what I outlined above, adjust to fit your preferences. I have 4GB of ram in my machine and use a heap size of 1024m and a permSize of 512m. You may need to go through a few test runs with different settings to find which one works best for your computer. You may find that only using 256m heap space is sufficient while you end up needing to increase your permSize to 128m. I'll leave it up to you to decide.
Conclusion
I hope some of you have found this tip handy. I know adjusting memory arguments is a topic that has been discussed to death since the dawn of Java, but I also know the vast majority of Eclipse users I help have no idea how to adjust the command line arguments that Eclipse uses nor do they understand why they would adjust them. This tip is also intended for folks that were never aware of the permSize arguments and what they can do for runtime performance as well as avoiding mysterious OutOfMemoryException s that make no sense.
I would encourage you all to share your own performance tweaks in your responses as I may have missed some really good arguments here that have helped you see some noticable improvements in performance or reliability. Thanks for reading.
37 replies so far (
Post your own)
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Thanks for the tip. I already use the -Xms and -Xmx parms, but I don't generally spend alot of time adjusting these parameters. Is there a reason why you tend suggest setting the size and max sizes set to the same value, for instance, -XX:PermSize=128m -XX:MaxPermSize=128m rather than something like -XX:PermSize=64m -XX:MaxPermSize=128m? (same for the -Xms and -Xmx parms).Just trying to understand the reasoning!
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
I think (as far as Eclipse is concerned), there's another switch: (-Dide.gc=true) which can also affect runtime performance. I am not sure how this affects it - but remember reading about it in some newsgroup.Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Mike,I'm not a VM expert, but my reasoning behind it is similar to the reasoning behind setting your Windows swap to have the same min/max; it's to avoid the cost of resizing the addressable space. I have no hard numbers to indicates this help, just something I thought 'made sense'.
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
i don't know for windows, but on linux it is better setlesser initial pool (-Xms) - you needn't max space , maybe and heap can increase - when eclipse spawn new process, then
this proccess have lesser initial pool and it work better
i think that is same on windows except winodw have any really bad swaping
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
it force memory garbage - it can helpRe: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Periodically, if Eclipse isn't doing anything (the user's not typing, there aren't any background jobs etc.) it calls System.gc() to request (rather than force) a garbage collection. Given the amount of objects (and arrays) that are transiently created during Eclipse's normal operation, it certainly helps clean these up.It's also why in Eclipse 3.1, the memory utilisation goes down after you stop using something; before, it would grow and grow and grow. For example, if you load a JSP in WTP, it needs to load a bunch of classes to deal with the JSP. If you close it, it doesn't need all of them any more and so they become eligible for garbage collection. Some VMs are intelligent and now release memory back to the OS, but they tend only to do so if you've requested a System.gc().
By the way, there's a horrible bug in Java 1.5 or Java 5 or JSE5 or whatever they're calling it these days (JavaBook Pro, anyone?) that causes System.gc() to max out and take the highest priority possible for doing System.gc() runs, which can temporarily interrupt processes on a single processor box. I gather that the bug has been fixed and is either in the latest (or upcoming) version.
Alex.
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
i agree that it can help, but no too much on linuxlinux memory managment is smart and unused memory swap to disk - you need enough swap (or memory) only
maximum swpa space is more important for linux
i don't sure for windows, but modern OS must have modern swapping
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Hi,is this applicable to WSAD?
Thanks.
Nirav
Re: Tuning Eclipse Performance and Avoiding OutOfMemoryExceptions
Yes I believe so since it is based on Eclipse. If the version of WSAD you are using is based on Eclipse 2.x, there is no .ini file and you need to specify the command line arguments directly in your shortcut or script you use to start WSAD.UI performance still poor under Linux.
I thought that maybe some of your trick could help with the slow UI I experience under Eclipse/GTK2 only but no luck.Its as slow as always
And Eclipse dev's almost stopped any tuning work since they use windows anyway for development and Linux is on the list of supported platforms. Cool!
Re: UI performance still poor under Linux.
Clemens,I thought a lot of work between the GTK/Pango and SWT team took place about a year ago to boost performance. Is this still not the case with the 3.1.1 or 3.2 releases?
Re: UI performance still poor under Linux.
what is your system (hardware) and what mean slow - do you use visual editor, maybe ?Re: UI performance still poor under Linux.
> what is your system (hardware) and what mean slow -> do you use visual editor, maybe ?
My system is a P4-2.6ghz with a Nvidia GeForce 488Go.
Anything which has to do with UI performance is slow like:
* View resizing
* window resizing
* menu-performance (though a lot better now with composite)
* scrolling complex text fast
For now my laptop dies do I work with my Athlon800 which is dual-boot. On windows Eclipse's ui is really fast and useable but obn Linux its nightmare. And my development-enviroment is linux
lg Clemens
Re: UI performance still poor under Linux.
> I thought a lot of work between the GTK/Pango and SWT> team took place about a year ago to boost
> performance. Is this still not the case with the
> 3.1.1 or 3.2 releases?
I currently use 3.1.1 but I only saw very small improvements between releases.
Motif of the fox port of SWT perform so well, is it really so hard to do the same with GTK2?
So either a concept of any involved libraries is broken or something else does not work right.
I don't know nore do I care - I know that these issues will not get fixed in near future havin a look at the performance bug at eclipse. I think it has the 2. most votes but the devs officially explained that they do not see the need nore are they willing to improve the GTK2 port further.
btw. netbeans runs a bit slow on my Athlon800 under Windows and Linux but performs superior un my P4-2.6ghz laptop.
lg Clemens