Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COM+ Error On 2000 server

Status
Not open for further replies.

Markahipp

MIS
Oct 18, 2001
2
US
I am currently running an C++ application on a Windows 2000 server that simply recives messages through the Mailslot and writes the recieved messages to a access database via a sequal statment using ADO.
The whole process works about 1000 times and then it will generate the following error in the Event Viewer:

Event Type: Error
Event Source: COM+
Event Category: Executive
Event ID: 4199
Date: 10/17/2001
Time: 7:36:16 AM
User: N/A
Description:
The COM+ Services DLL (comsvcs.dll) was unable to load because allocation of thread local storage failed.

Process Name: Server Status Window.exe
Error Code = 0x80070008 : Not enough storage is available to process this command.
COM+ Services Internals Information:
File: .\comsvcs.cpp, Line: 289

I can clear this problem up by simply stopping the application and restarting it.

Here is the c++ function:

#include <stdio.h>
#include <string.h>

#import &quot;C:\Program Files\Common Files\System\ADO\msado15.dll&quot; no_namespace rename(&quot;EOF&quot;, &quot;EndOfFile&quot;) // requires at least version 2.61.7326.0

void main (void)
{

CoInitialize(NULL);
try
{

_ConnectionPtr Conn(&quot;ADODB.Connection&quot;);
Conn->Open(&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\inetpub\\logonmsg.mdb;&quot;,&quot;&quot;,&quot;&quot;,adConnectUnspecified);

sprintf(sqlstat, &quot;INSERT into Messages (Dates,Times,Type,UserID,Source,Computer,Description) VALUES ( %s,'%s','%s','%s','%s','%s','%s')&quot;, da, tim, typ, usid, org, comp, des);

Conn->Execute (sqlstat, NULL, adCmdText);
Conn->Close();

}
catch(_com_error &e)
{
printf(&quot;Description = '%s'\n&quot;, (char*) e.Description());
}
::CoUninitialize();
}

And help would be appreciated!

Thanks!
Mark
 
I started wondering why the comsvcs.dll was being &quot;reloaded&quot; at all since it should be loaded only once and remain in memory until application shutdown. I have noticed that comsvcs.dll gets loaded once the ado connection object actually makes a connection (i.e., with the Open method).

If I look at the modules loaded by my application
immediately after it starts, sure enough the comsvcs.dll is loaded into memory. However, if I let the application run for a while and check back, usually the comsvcs.dll is not loaded into memory. What I can't figure out why this dll is
being unloaded, since my understanding is that normally a dll will remain loaded until explicitly unloaded.

I have another service that keeps a database connection open the entire time that it runs and I don't see this same problem with that application. So, I have changed the code in the problem application to keep the ado connection open until application shutdown to see if the problem goes away. I would prefer to not keep a connection to the database open the entire time, but it is preferable to the alternative (the application failing).
 
Turns out the problem is not connection.open. Microsoft has confirmed that there is a leak within CoInitialize() and CoInitializeEx(). I have changed my app to initialize only once during its existence, and now seems to run fine :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top