(Possible?) Answer to slow image resizes in ColdFusion 8

This post is more than 2 years old.

For a while now I've seen an odd issue with image resizing on the Mac (and then Windows as well). Sometimes when I would resize an image, it would take an extremely long time to finish. I'm not talking about expected slowness for a large image/high quality resize. I'm talking about some images take a few seconds, and others taking well over 2 minutes while my CPU went thermonuclear.

This was very hard to reproduce, although I had one image by Steven Erat that seemed to be pretty consistently 'bad' in terms of tripping up this issue.

Other people have not always been able to reproduce this. I know Jared has seen it, but I'm not sure many other people. RIAForge seemed to suffer from it for all images when doing screenshots.

So anyway, it was a very odd issue and that was hard to test. I spoke to Adobe engineering this morning and they pointed out that it was a confirmed bug in the 1.5 JDK. I switched my ColdFusion to use 1.6 and at first it didn't help. I did a quick check and saw that I was at: build 1.6.0_07-b06-153

I went to Apple's Java downloads, grabbed the latest update, and went up to 1.6.0_13. After restarting ColdFusion, the previous resize which had taken around 48 seconds went down to 800ms.

Hope this helps others.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by James Allen posted on 5/14/2009 at 7:08 PM

Another good reason - aside from the object instantiation bug in older versions - to keep Java 6 as up to date as possible.

Comment 2 by Joshua Siok posted on 5/14/2009 at 7:40 PM

Great tip Ray. I've had problems recently with cfimage and CMYK jpg's also seeing performance hits when resizing. I've also had other buggy behavior with CFImage where I can't load an image (using action="read") into a local variable because CF thinks "it's not a supported format". But when I i do action="resize" and use the same image as source, I don't get any errors. So maybe this problem will be solved as well. I'll be sure to get Java up-to-date ASAP!! Thanks Ray!

Comment 3 by Daniel Short posted on 5/14/2009 at 8:01 PM

I've had these issue quite a bit. I'll be trying an update to _13 this evening. Hopefully the upgrade will get rid of these:



Comment 4 by Simon posted on 5/14/2009 at 8:04 PM

Can anyone recommend the safest way to update the JVM on a windows machine? I'm nervous that I'll have problem when restarting the service.

Comment 5 by James Allen posted on 5/14/2009 at 8:22 PM

No need to worry. The new JVM will install in a new directory so you will be able to switch back to the old one quickly if you get re-start problems. This is how I did the upgrade on Server 2003.

1. Install the latest JVM and note down the path. On my system the path is (I'm running v12):
C:/Program Files/Java/jdk1.6.0_12

2. Edit the jvm.config file (on my multiserver installed version of CF8, this is in C:\JRun4\bin

3. Find the 'java.home' line and comment out. Then add a new line for the latest JVM - mine looks like this:

java.home=C:/Program Files/Java/jdk1.6.0_12

4. Restart the JRun or Coldfusion service.

If there are any problems you'll get an error and can then simply uncomment the original java.home line and remove the new one.

The only problem I had was installing the JDK instead of the JVM.. :)

Give it a go.

Comment 6 by Sean Coyne posted on 5/14/2009 at 9:07 PM


The new java home path needs to point to the JRE not the JDK so from your example it would be

C:\Program Files\Java\jdk1.6.0_12\jre
C:\Program Files\Java\jdk1.6.0_12

other than that it should work fine.

Comment 7 by Raymond Camden posted on 5/14/2009 at 9:13 PM

@SeanCoyne: I've made that exact same mistake in the past.

Comment 8 by Raymond Camden posted on 5/14/2009 at 9:21 PM

I should add - I reloaded the page a few times and the 800ms went to do around 400. So it got even quicker.

Comment 9 by Sean Coyne posted on 5/14/2009 at 9:22 PM


jedi make mistakes?!! :)

Comment 10 by Raymond Camden posted on 5/14/2009 at 9:24 PM

Most of my blog entries are based on my mistakes. Folks have this mistaken view that I'm smart. I'm not. I just blog _everything_, which includes all my mistakes. ;)

Comment 11 by James Allen posted on 5/14/2009 at 11:42 PM

That path is exactly what I am using on my install and it's working fine - I took it from my jvm.config.

Wonder if my install is slightly different. Strange.

Comment 12 by Elliott Sprehn posted on 5/15/2009 at 5:00 PM

Where do you see Java 1.6.0_13 on the Apple website?


The newest update on that page is for 1.6.0_07.

Comment 13 by Rob posted on 5/15/2009 at 5:33 PM

@Elliot - I don't even see that. Latest I can find is this: "Java for Mac OS X 10.5, Update 1 adds Java SE 6 version 1.6.0_05 to 64-bit Intel Macs."

Comment 14 by Raymond Camden posted on 5/15/2009 at 5:43 PM

Not sure what to say, and I don't have the URL with me, but I do remember them saying it wasn't fully tested. So maybe it is a beta version. It's working finr for me so far.

Comment 15 by Elliott Sprehn posted on 5/15/2009 at 6:28 PM


Are you sure it's 1.6.0_13? I don't think that exists for OS X.

Can you give us the java -version output?

I logged into my ADC account, and it's not even there.

Comment 16 by Elliott Sprehn posted on 5/15/2009 at 6:30 PM


That's because they forgot to update the java listing page.

If you click the link in my previous post and look at the middle of the page there's info about "Java for Mac OS X 10.5 Update 2".

Here's the KB article:

Comment 17 by Raymond Camden posted on 5/15/2009 at 6:32 PM

java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-196)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-77, mixed mode)

Comment 18 by Elliott Sprehn posted on 5/15/2009 at 6:40 PM

Ah, I found it.

The only way to download this is to login to http://connect.apple.com/ and then look at the Java downloads. The accounts are free in case anyone wondered.

It's a Developer Preview of Java for OS X and not officially supported or distributed yet.

Comment 19 by Raymond Camden posted on 5/15/2009 at 6:41 PM

Thanks for digging it up Elliott.

FYI to folks - I wouldn't normally do an unofficial JRE but as this is a developer machine, I didn't care.

Comment 20 by Elliott Sprehn posted on 5/15/2009 at 7:12 PM

I can't even get CF to start with this update installed.

05/15 11:22:12 error Could not pre-load servlet: ColdFusionStartUpServlet
[1]java.lang.UnsupportedClassVersionError: Bad version number in .class file

Followed by lots of NPEs as a result of that I think.

Are you sure CF is starting with Java 1.6 Ray? After installing that update if you don't change the symlink for /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK to point to 1.6 CF will start with 1.5 instead.

Comment 21 by Raymond Camden posted on 5/15/2009 at 7:13 PM

Elliott, I wonder if it is the version of CF I'm using. I'm using, um, a "special" version. One you have as well. I'm not using it on a stock 801.

Comment 22 by James Allen posted on 5/15/2009 at 7:15 PM

Ooooh look at you.. Mr Fancy 'pre-release' Pants.. ;)

Comment 23 by Elliott Sprehn posted on 5/15/2009 at 7:16 PM

I'd be weary about this blog post then. Anyone who doesn't have that, um, "special" version will break their entire install.

Comment 24 by Raymond Camden posted on 5/15/2009 at 7:17 PM

Let me try my stock 801 though. Just to be sure.

Comment 25 by Raymond Camden posted on 5/15/2009 at 7:20 PM

Elliott, it's working just fine in my 801: 8,0,1,195765 That isn't "stock" though, that's 801 with the last CHF I believe.

Comment 26 by Elliott Sprehn posted on 5/15/2009 at 7:27 PM

Hmm, it seems that the usual trick of changing that symlink doesn't work anymore.

If all you do is change CurrentJDK CF will start with 1.5, but load lots of 1.6 code from the framework which is very odd, and also broken.

Once I changed 1.6 to be the preferred JVM in the Java Preferences.app it all worked fine. How odd.

Comment 27 by Raymond Camden posted on 5/15/2009 at 7:29 PM

Ah, that's how I did it. Don't use links very often so it didn't even occur to me.

Comment 28 by Elliott Sprehn posted on 5/15/2009 at 7:38 PM

Yeah. That didn't work way back on 10.4 to make CF use 1.5 as the JVM instead of 1.4 so I got in the habit.

Anyway, thanks for the tip about the java update, and sorry for the comment thread hijack!

Comment 29 by James Allen posted on 5/15/2009 at 7:44 PM

Just to add to the path I specified above, even though the path in my jvm.config is set to:

C:/Program Files/Java/jdk1.6.0_12

Coldfusion administrator reports this path is being used:

C:\Program Files\Java\jdk1.6.0_12\jre

So at least on Server 2003 specifying the path *without* the JRE works fine.

I am intending to video blog the upgrade process soon to help anyone who is a little uncertain on how to perform it on Server 2003.
Will add comment when done.

Comment 30 by tony petruzzi posted on 5/16/2009 at 5:20 AM

i don't know why people don't check at least once every couple of months for the latest java version and install it. it's not like you can't roll back to an earlier version if things go south. upgrading your jvm should be THE first thing you do when you have problems or weird issues with cf.

on the flip side. after you've updated your jvm you can use javara to remove the previous version and free up some space.