Eclipse IDE - Improving the memory hog

I stopped using Eclipse IDE quite a while back for a couple of reasons. Firstly, I wanted to explore what other IDE’s were available, and secondly I thought it was a bit of a memory hog. There is nothing worse than having to restart your IDE every couple of hours when you are deep in fixing code.

I downloaded Helios the other day from the PDT Project site which has PHP ready for use. After hunting around, I came across something I thought I’d try, and it made quite a lot of difference in the speed.

Open up the eclipse.ini file inside the eclipse folder (might be best to make a copy of it just in case!). Remove the -Xms40m and -Xmx384m lines from the bottom. Now put this in at the bottom:

-Xms128m
-Xmx512m
-XX:MaxPermSize=120m
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing

Now start Eclipse (or shut it down and restart if you already had it open). Notice any difference?

So.., you may be asking, what does all of this do? The notes below are taken from this garbage collection (GC) article.

Heap size

-Xms256m
-Xmx512m

The more the better…

Perm size

IntelliJ likes a lot of memory for caching references and class meta information. That is why we need to make sure that cache is not purged. Cache is stored in ‘Old Generation’ space which size is determined by the following option

-XX:MaxPermSize=200m

General rule is to observe memory indicator after using find symbol option with include non project files selected. If it doesn’t move you have chosen enough memory.

Maximum Pause

-XX:MaxGCPauseMillis=10

We ask GC to pause the application for no more then 10 milliseconds.

Proportion of free space

-XX:MaxHeapFreeRatio=70

We ask GC to kick off when more than 30% of memory is occupied, so when we start compilation GC will not interfere because it will be enough memory free.

Concurrent Mark-Sweep (CMS) Collector

-XX:+UseConcMarkSweepGC

We want GC to run in parallel with other threads without freezing the application. This option doesn’t stop GC from freezing the application but it reduces it significantly.

Incremental Mode

-XX:+CMSIncrementalPacing

We don’t wont to freeze the application so we do GC incrementally with breaks so the application can take a breath. We use Pacing so GC can learn how to use CPU based on application CPU usage.

Filed under  //   code   development   eclipse   ide   memory   php  

Improving performance for Drupal development on localhost

I usually use virtual machines for development if I am on Windows. On this machine I have several VM's with different flavours of Linux for that purpose. However, I also have a WAMP installation which I use if I want to muck with a test Drupal site or just try out some stuff.

As a lot of people out there know, WAMP and XAMPP can really suck at performance. I remember in the past waiting 40 seconds for a page load on a Drupal site which was pretty clean, which of course is enough to make you want to rip your own hair out. After firing WAMP up today for the first time in months, I thought I'd have a hunt around to see if there were any solutions to this problem. Here are two things I found that made quite a difference on my system.

1. Adjust the realpath_cache_size in php.ini, and set it to a reasonable level. I set mine to 24 meg which is probably a bit too high, some people are saying that even 2 meg gives them improvements. In WAMP you can edit the php.ini file by clicking on the WAMP icon in your toolbar, scrolling up to the PHP section, and clicking on php.ini. Find the line that starts with ;realpath_cache_size, and uncomment it out, so it should now read:

realpath_cache_size=24M

2. Disable the IPv6 line in your Windows hosts file (note this will only work on Vista and 7, not XP). You will need to do this as adminstrator, so you may need to right click on the hosts file and choose 'open as administrator'. The file is located at C:\Windows\System32\drivers\etc
Change the line:

::1             localhost

to

#::1             localhost

and save the file. Basically all you are doing is commenting the line out with a hash (#) so it's not used.
See if that makes any difference. I noticed it made an improvement to my overall system, not just WAMP. If you see no difference, then you can always re-edit the hosts file and remove the hash to enable the line again.

 

Filed under  //   development   drupal   localhost   performance   php   server