COM+ memory problems

Hi,

I write an application that uses COM+ to access the application layer on a server. The server is written using MSVC 6 and ATL.

My Problem is that when the server is heavily loaded I get a very high memory consumtion of the dllhost.exe that is running my COM-Server. That would be no problem, but when all objects are released again, the memory consumtion doesn't go down again.

What could be the cause of that and what how can I release that memory again?

Thanks
Overmind
LVL 2
AcrklorAsked:
Who is Participating?
 
d2hilstConnect With a Mentor Commented:
Hi Acrklor,

I'm not sure how to help you, but I write what I think based on your description and you might get an idea as to what causes the problem, ok? :-)

Step 1-2 is probably not a leak. By logging on, you mean that you create the COM object? If so, the dllhost increase in memory is most likely caused by dll:s that are needed by the COM system are loaded.

Step 2-3 is a big leap for starting a COM object, but it can be explained if the object uses some other stuff that needs a lot of memory and external dll-resources (for example a database connection). A bit more alarming is the fact that it is not returned when the COM object is destroyed (#11). I can think of 2 reasons as to why;

1. The object is not properly released.
How do you store your COM pointer (plain pointer, smart pointer...)? If you store it as a plain pointer, check the return value from Release (should be 0 to deallocate the object).  

2. The memory is allocated due to dll loads.
If the COM object actually uses a lot of dll resources, they can remain in memory after you destroy the COM object. You can test this by creating a new object after #11, i.e. reconnect/restart the test sequence. If the memory stays about the same after logon, everything is ok. If not, check the pointer release stuff again...

3-10; Starting and stopping the module, is probably caused by a leak. You wrote that you think it is possible that you may have one or two small leaks. If the module you are running is repeatingly running the same pattern many times, this can cause rather big leaks. The memory is allocated in chunks, and if you only return 99% of the used memory in your deallocation, the last 1% will cause big leaks (memory fragmentation; the chunks cannot be deallocated until all individual bytes are deallocated)

As is wrote above, I'm not sure this will help you, but it might give you an idea as to what's wrong.

Regards,

Stefan
0
 
d2hilstCommented:
Hi,

This sounds a bit strange, can you please supply some more information? If you run your client for a while, can you
actually see the memory usage for the dllhost application go up? And if you bring the server down in this state (by shutting down the client), the memory is not returned to Windows?

I have worked quite a lot with COM/COM+ on Windows NT/2000 and my experience is that it is very unusual for Windows
NT/2000 to loose track of (memory) resources this way.

Is the client also a C++ application?

Are you developing on Windows 2000/XP/...?

Does the server application use other COM+ components?

Without knowing more in detail about your environment/applications, my best recommendation would be to ask you go through the memory allocation in both the server and client. In my programs memory allocation errors is by far the most common mistake (but that's me ;-)


Regards
/Stefan
0
 
AcrklorAuthor Commented:
Hi,

Both client and server are developed with MSVC 6 on Windows 2000 and the application uses no other COM+ components.

The memory loss seems to me like a kind of caching, here is a short example of the memory loss:
1.) wihtout any action dllhost takes about 4000k
2.) client logged on: dllhost.exe goes up to 6500k
3.) client starts module A: 12000k
4.) client ends module A: 11000k
5.) client starts module A: 12000k
6.) client ends module A: 11000k
7.) client starts module B: 13500k
8.) client starts module A: 14500k
9.) client end module B: 14000k
10.) client ends module A: 13000k
11.) client logged off: still 13000k

If I have started all functions I'm up to about 45000k, the problem is that the memory consumption still increases at this point (about 100-500k in modul), but not as fast as in the beginning. I'm not sure if every byte is freeed correctly ;-), but I'm sure it shouldn't be that much, every of our own objects is released.

thx
Acrklor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.