JRun running out of memory

I have had ColdFusion / JRun memory problems on projects in the past but are always very tricky to pin down. However, recently when a couple of my sites have started ranking at top positions on Google I have been experiencing a lot more crashes from our ColdFusion 7 server. Enough was enough and I decided I must sort this out once and for all.

I am running four ColdFusion instances with all of the sites I host spread across them. This has the benefit of me being able to allocate larger chunks of memory to each instance, monitor their load easier and reduce the risk of downtime for the other instances if one does happen to crash.

One of the sites in question normally receives on average about 1200 visitor sessions per day but on this one day the visits shot to over 11,000 - Great you might think. I suppose yes it would be, however with the amount of sites running on the server, the memory very quickly started shooting up and I had to restart the ColdFusion instance several times during the day.

Each time the server crashed, when I logged onto it to terminated the hung ColdFusion instance I would get the following error on the desktop:-

The instruction at 0x0000000 referenced memory at 0x0000000. The memory could not be read. Click on OK to terminate the program
The instruction at "0x0000000" referenced memory at "0x0000000". The memory could not be "read".
Click on OK to terminate the program

This is in no way ideal as the eBay API I use on one of the sites takes about 15 minutes to download, build the stubs and then compile the Java files into classes. This meant that during that time I could no longer process requests properly and they started queuing up and causing further problems. I managed to alleviate this by only allowing the initial request to invoke the web service and then denying everyone else for another 20 minutes until Jikes had finished compiling everything. Since then, I have migrated my code to use the eBay XML API rather than a web service - Starts instantly and is just as easy to implement. Anyway, that's all by the by.

Jrun Server Error

Even after doing this, I still had the problem with JRun crashing and giving the dreaded error:-

Server Error

The server encountered an internal error and was unable to complete your request.

Could not connect to JRun Server.

Last resorts

I tried several things in desperation such as reducing session timeouts to 5 minutes. This didn't help, and only annoyed webmasters using our CMS who would take ages typing something in only to find when they went to save their session had ended. And yes, before someone mentions it, I could put an AJAX function to auto refresh their session every 1 minute. I'll get round to that later.

I tried altering some of the code that maintains data in session variables and using client variables instead, no joy there either.

Eventually, I took time out and actually thought about what was causing the problem rather than wild stabs in the dark - That's when it hit me! A while back I was doing some SQL server profiling on one of my databases and noticed there were duplicate threads active for the same datasource which just weren't being closed.

Nirvana

I hastily logged onto our web server and amended the datasource of the busy site, unticked the "Maintain connections across client request" check box. The result was INSTANT! As you can see from the FusionReactor graphs below, once I unticked that box and hit submit, the memory dropped like a stone.

At the point in time just before I hit submit the memory usage had steadily increased to 380mb used. After saving the datasource it dropped down to 167mb and stayed steady at that level for the next few days while I was monitoring it.

Notice the ColdFusion instance was restarted at 10:46 and by 12:38 it had reached 309mb free
Memory after - According to FusionReactor
After the changes were made to the 2 data sources, the memory dropped like a stone and has been sitting very happily at circa 250mb for days now.

Conclusion

It would appear that on high-traffic sites, or as in our case servers with 100 or so ColdFusion driven web sites that if the busier ones maintain connections to the database then it is possible that you may experience these JRun memory problems.

I haven't yet played around with Limiting connections as I was just happy not to have to restart the ColdFusion service every few hours.

It is also possible that specifying a shorter timeout in the datasource may also help - So a "proper" visitor who is visiting more that just one page on your site will benefit from the fact that the connection has been maintained. While a "passer by" who hits the home page, decides they're not really interested and leaves will only tie up the resource for 1 minute maximum.

I would be interested to know of other peoples experiences - so please, post your comments here.

Key phrases:-

  • JRun out of memory
  • ColdFusion service crashes or hangs
  • Server Error
  • The server encountered an internal error and was unable to complete your request.
  • Could not connect to JRun Server.

Applies to:-

  • ColdFusion MX7 Enterprise
  • MSSQL Server
  • MYSQL

Hardware:-

  • Dell Poweredge 2850
  • 4gb RAM
  • Dual 3.2ghz HT Xeon processors
  • Dell PowerVault P220S storage device

Links:-

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
You should get a thread dump to see what's really going on when it's hung and what's stuck. Unchecking "maintain connections" shuts off connection pooling.

While this lessened the symptom and gives you some information, this probably didn't solve the problem.

Things to check:
- do you have a license-limited SQL Server (20) but use an unlimited connection pool in the datasource (things will back up in this case).
[ You'd see this in a thread dump ]
- do you use client variables stored in the database?
[ If connections got backed up, you'd see this in a thread dump ]
- what version of the driver do you have? (Macromedia_drivers.jar). This might be a symptom of a problem with a certain version of the drivers.

Stephen
# Posted By Stephen Dupre | 05/02/07 16:10
Hi Stephen - I've not looked at any thread dumps from the time as by the time I managed to get onto the server it had already crashed and even FusionReactor had died by that time.

- SQL server isn't limited to any amount of connections (Set to 0 - Unlimited)
- Client variables for each of the ColdFusion instances are on the SQL box
- Driver version is the one that came with MX7 updater 2 - Not sure how to tell what version it actually is though!

Martin
# Posted By Martin Parry | 05/02/07 18:12
I keep getting "could not connect to jrun server" when trying to access classes at upledger. Does anyone know how I can connect
# Posted By Marina Del Ray | 29/05/07 04:26
"Jrun connection closed."
I had this very often after going to coldfusion MX 7.
In fact I use a heavy library causing this error.
I uncheck the WHITESPACE MANAGEMENT box... a lot of whitespace od course but NO MORE ERROR !!
# Posted By Denis | 11/06/07 21:59
Interesting you should say this... I have since read about whitespace management causing problems. I have coded my own tidy up routine which interacts with getPageContext().getOut().getString() - I do this in onRequestEnd. I also use it to not only compress the page but to alter meta tags etc dynamically based on the previous request.
# Posted By Martin parry | 02/07/07 16:14
- SQL server isn't limited to any amount of connections (Set to 0 - Unlimited)
- Client variables for each of the ColdFusion instances are on the SQL box
- Driver version is the one that came with MX7 updater 2 - Not sure how to tell what version it actually is though!

http://www.dir-9.com
# Posted By pete | 23/11/07 00:22
C:\CFusionMX7\lib>set classpath=c:\CFusionMX7\lib\macromedia_drivers.jar;%CLASSPATH%

C:\CFusionMX7\lib>java macromedia.jdbc.sqlserver.SQLServerDriver
[Macromedia][SQLServer JDBC Driver]Driver Version: 3.50.15 (016222.009407.011314)


This shows SQLServer driver 3.5 build 15.

The version nomenclature is confusing.
There's
-ColdFusion 7(.0.0) Hotfix #2
-ColdFusion 7.0.2
-ColdFusion 7.0.2 Hotfix #2

There are many behaviors in this thread. Some are related to client variable connections (java, internal calls inside the cfusion.jar) that weren't closing correctly. The originator of this thread saw this problem and proved it by profiling. That's why shutting "maintain connections" OFF worked.

But if you're on 7.0.2, this fix should be in the code. (this was originally a 6.1 phenomenon).

Get a thread dump when the system is stuck (technote 18339). That might help debugging as well as monitoring SQL Server connections.

Find out the driver version you have too. It's rare but sometimes .jar files aren't updated.


Others may have a combination of OTHER problems.
# Posted By Stephen Dupre | 23/11/07 15:02
Thanks for posting this Stephen - Hopefully it is fixed in the latest version, and indeed CF8

Martin
# Posted By Martin Parry | 01/12/07 10:29
Can often be related to a large request that is buffered in memory. Check for large datasets or a resposne that is not written out (e.g. composing a large XML file) but is cached in the Jrun server.
Here is a good article about those hard-to-detect application hangs: http://www.correlsense.com/cto-blog/top-3-reasons-...
# Posted By Nick Batell | 03/01/08 15:00
I had this very often after going to coldfusion MX 7.
In fact I use a heavy library causing this error.
# Posted By automotive repair manual | 11/01/08 02:41
There are many behaviors in this thread. Some are related to client variable connections (java, internal calls inside the cfusion.jar) that weren't closing correctly. The originator of this thread saw this problem and proved it by profiling. That's why shutting "maintain connections" OFF worked.
# Posted By adum | 05/04/08 06:01
I was having similar issues on one of the Coldfusion instances that I maintain. I was running on Windows Server 2008, with Coldfusion 8 Enterprise and every couple of hours jrun would consume all the RAM and crash. I unchecked the "Maintain connections across client requests", and everything became stable.

Thanks for this great blog post this save lot of money and downtime!
# Posted By Kaitlyn Kresek | 29/05/08 14:36
You may want to kill the 'feedogator' comment. The link opens some 'Buy some AV software to fix your virus' BS
# Posted By Steve 'Cutter' Blades | 07/08/08 16:11
I am experiencing a similar problem with cf 6.1 returning an out of memory error after iterating over a 395K records dataset. I am an transfering information between an Oracle data source and MS SQL server 2000. The current code is working, however I am trying to retrieve 3 more fields from the source data and transfer them into the MS SQL data and this is where my problem lies. I figure that my exisiting code must be running pretty close to the mem limit then.

As I am iterating over the source data, validating it row by row and then inserting it in the destination table could this connection ppoling be running me out of memory and where do I find the tools to monitor memory use on CF 6.1

We are on Win 2003 servers and do not have multiple JRUN/CF instances

Thanks in advance for any handy info

Gus Denton
# Posted By Gus Denton | 10/10/08 06:35
hI I AM GETTING THE SAME JRUN ISSUE - IT SEEMS TO LESSON WHEN I REDUCED THE AMOUNT OF DATA I WAS RETREVING FROM opp s caps . from the database. But i still get crashes. Is two querys on a page two much. And is using the cached within parameter going to eat jrun memory.
Im on godaddy can i access this "maintain connections" for myself?. ya three questions i know
# Posted By JAMES BEUTHLING | 28/02/09 21:41
I am experiencing a similar problem with cf 6.1 returning an out of memory error after iterating over a 395K records dataset. I am an transfering information between an Oracle data source and MS SQL server 2000. The current code is working, however I am trying to retrieve 3 more fields from the source data and transfer them into the MS SQL data and this is where my problem lies. I figure that my exisiting code must be running pretty close to the mem limit then.

As I am iterating over the source data, validating it row by row and then inserting it in the destination table could this connection ppoling be running me out of memory and where do I find the tools to monitor memory use on CF 6.1
http://www.limewire.bz
We are on Win 2003 servers and do not have multiple JRUN/CF instances

Thanks in advance for any handy info
# Posted By limewire | 23/05/09 08:33
BlogCFC was created by Raymond Camden. This blog is running version 5.9.5.002. Contact Blog Owner