Out of memory: 'Server.CreateObject'

P

Peter Koller

Hi group!

I am getting the following error from my ASP application:
Microsoft VBScript runtime error '800a0007'

Out of memory: 'Server.CreateObject'



It always (as far as i have observed) occurs when i try to create a new
ADODB.connection object in my cCon helper function (opening a connection and
returning it):

Function cCon()
Dim cnRet
set cnRet = server.createobject("ADODB.Connection") 'This is where the
error is thrown
cnRet.connectionstring = GLB_CONSTR_DB
cnRet.open
Set cCon = cnRet
End Function


The page that errors will typically call this function 6- 10times from
different functions which handle their connections in this way:

Function Foo()
dim Con ...
Set con = cCon()
.... function code
con.close
set con = nothing
End Function

All my recordsets are disconnected and also destroyed with .close and Set
rst = nothing.

I have tested the application on two seperate servers with the same result.

Both machines had more than enough memory.

I have also checked the application log to see if anything was logged, but
there wasnt.

Any one got ANY ideas on this one? I'm starting to get desperate!
 
P

Peter James

Peter
Looks to me like every time you call cCon() you create an object *cnRet* but
it is never destroyed. In function foo() you create another object *con*
which is destroyed on completion, but I doubt that that destruction will
cascade back to *cnRet*.

If it is not a rude question - why use a helper function to create an
ADODB.connection object? It is a straightforward action unlike a Win32 API
call for example.

HTH

Peter
 
P

Peter Koller

Won't the local "pointer" cnRet be destroyed when it goes out of scope?
Anyways, the reason for cCon() is lazyness, one line instead of three..

I tried to "manually" open the connections in my functions without using
cCon(), but i still error, atlhough this time when reading a session
variable (i only have one session variable holding an int so its not that
either).


In perfmon i have at least 200mb of free memory at all times. The maximum
amount of connections to my sql server is 6.
 
P

Peter James

Peter
Perhaps you should read Aaron Bertrand's many posts on the subject of
ADODB.connections, and look here http://www.aspfaq.com . The (sound)
philosophy is to create your object *when* and *where* you need it, and then
destroy it asap having used it. This is by far the most robust way, even if
it means putting the same lines of code in many scripts.

HTH

Peter
 
M

Mark Schupp

Follow-up

Just checked the function I mentioned in my other post. It is different from
yours in that we do not use an intermediate variable. Your function would
look like:

Function cCon()
set cCon = server.createobject("ADODB.Connection")
cCon.open GLB_CONSTR_DB
End Function

I don't think that this should make any difference but you might try it.

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
(e-mail address removed)
http://www.ielearning.com
714.637.9480 x17
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top