Server Time:
Sunday May 11 2008 08:11 PM  
Your Time:
  
HostMySite.Com is sponsoring this tutorial, please visit their site today!
This tutorial is sponsored by HostMySite.Com - ColdFusion Hosting

Memory allocation error
by: Anthony Moore
Email this tutorial to a friend Display Printer Friendly Format
[Download in PDF Format] [Download in FlashPaper Format]

Recently I have had some difficulties with ColdFusion getting the ODBC Error Code = S1001 (Memory allocation error) error. I have read many articles trying find solutions to this problem but nothing that actually solved the problem. I have made sure of locking all my application and session variables as well as fine-tuned my queries to pass as little information as possible to and from the database server. I must admit that some progress has been made but under heavy traffic, eventually ColdFusion returns the S1001 memory allocation error. At this point I’m pretty much screwed. I do not have access to the ColdFusion service running on the web server and must rely on the IT staff to restart the service. As you might know, waiting on someone else to restart the service can seem like an eternity while you helplessly watch your website come to a screeching halt. This can be even more frustrating when it is the weekend and no one can be found to restart the service. As my site generates more traffic, it becomes even more imperative to ensure that ColdFusion is up and running. 

I thought, if I could just get access to the services running on the server… but then it occurred to me that while I don’t have security privileges to start and stop services, ColdFusion does! Why such a simple fact evaded me for so long I do not know why, but I have finally been able to write some code that will cause ColdFusion to restart itself and has been a life saver for me.

When ColdFusion gets the S1001 Memory Allocation Error (or any error that demands the service to restart) I execute the following code in my error.cfm (called by the <cferror> tag )…


<cfif findnocase("ODBC Error Code = S1001", error.diagnostics)>
    <cfset outfile=
"d:\mydir\ss.txt">
    <cfset cmd=
"d:\mydir\ss.bat">
    <cfset args=
"">
    <cfexecute name=
"#cmd#"
                    arguments=
"#args#"
                    outputfile=
"#outfile#">
    </cfexecute>
</cfif>



The contents of the ss.bat:


@Echo off
date /t
time /t
net stop "Cold Fusion Application Server"
net start "Cold Fusion Application Server"
exit




Contents of ss.txt after execution:

Fri 06/13/2003 
12:23p
The Cold Fusion Application Server service is stopping.
The Cold Fusion Application Server service was stopped successfully.


The Cold Fusion Application Server service is starting.
The Cold Fusion Application Server service was started successfully.


<cfexecute> executes the contents of the ss.bat batch file which directs the ColdFusion service to stop and then start. Once this code is executed the service is up and running again. I do not have to worry about the service sitting in limbo any longer. Of course someone has to get the error in order for the <cferror> to execute. However with careful planning and using the <cftry><cfcatch> you will be able to catch this error and immediately act upon it restarting ColdFusion automatically when needed.


Date added: Fri. June 13, 2003
Posted by: Anthony Moore | Views: 9407 | Tested Platforms: CF5 | Difficulty: Intermediate
Categories Listed: Error Handling

HostMySite.Com is sponsoring this tutorial, please visit their site today!
This tutorial is sponsored by HostMySite.Com - ColdFusion Hosting

Please rate this tutorial:
5 Stars 4 Stars 3 Stars 2 Stars 1 Stars
Post a new comment on this tutorial
post a new comment on this particular tutorial
Your Name:
Your Email:
Comment Title:
Comments:
Key Phrase:
 
Skyscrapper Banner Advertisement
ProWorkFlow.Com

You are 1 of 710 active sessions! | Privacy | Company
Copyright © 2002 EasyCFM.Com, LLC. (Easy ColdFusion Tutorials) All Rights Reserved
All other trademarks and copyrights are the property of their respective holders.
ColdFusion Hosting ColdFusion Hosting
ADD TO:
Blink
Del.icio.us
Digg
Furl
Google
Simpy
Spurl
Y! MyWeb