Hi,
We have a C# app that uis running as a service.
It uses a third party activeX dll that we us to capture events.
Because it is an activeX dll, we have to create our own message pump on a
thread (I Quite simple call application.run() on a new thread just after
creatign eh activeX component)..
All this works fine, but we have noticed that we are getting quite a memory
leak when running as a service.
Over the weekend, the application was running and this morning has consumed
300+ MB of ram. Normally sits in 5!
I have tried forcing GC every minute or so. This seems to help the situation
a bit.
Is there a known issue with ActiveX through interop and services?
Cheers,
Steve 5 3130
SPG,
I don't think that you should be calling Application.Run to establish
the threading model of the thread that the code is running on. If anything,
I would create a new thread in the OnStart method, and then set the
ApartmentState property of that thread to STA (or MTA, if you need it).
Then, on that thread, you would perform your work.
Also, are you calling the static ReleaseComObject on the Marshal class
to release all of your COM objects when you are done with them? You should
be aware that if one object you create exposes a property which exposes
another COM object, then you have to call ReleaseComObject on that as well.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"SPG" <st*******************@nopoo.blueyonder.co.uk> wrote in message
news:nL*********************@news-text.cableinet.net... Hi, We have a C# app that uis running as a service. It uses a third party activeX dll that we us to capture events. Because it is an activeX dll, we have to create our own message pump on a thread (I Quite simple call application.run() on a new thread just after creatign eh activeX component)..
All this works fine, but we have noticed that we are getting quite a
memory leak when running as a service.
Over the weekend, the application was running and this morning has
consumed 300+ MB of ram. Normally sits in 5!
I have tried forcing GC every minute or so. This seems to help the
situation a bit. Is there a known issue with ActiveX through interop and services?
Cheers,
Steve
> Also, are you calling the static ReleaseComObject on the Marshal class to release all of your COM objects when you are done with them?
Can I just add that this means *ALL* com objects, i.e. including the ones
that get created in the CCW that you don't ever 'see'.
For instance, if you use Excel as such:
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWbk = xlApp.Workbooks.Add();
you may be forgiven for thinking you've only requested two
COM objects - an Excel.Workbook and an Excel.Application,
hence if you release them, then Excel will be able to be freed.
But no - you've requested 3, an Excel.Workbooks collection
aswell.
You may need to put your code in more lines than you otherwise
would for a standard gc library - so you get references to *every*
COM object you create so that you can then destroy it explicitly.
The CCW *WON'T* do this for you!
Hi,
Thanks for the response.
OK, First things first..
If I do not call Application.Run(), then I do not get any events from my
activeX objects. I spent ages trying to make this work using a simple new
thread in Apratmentstate.STA etc, but until I called Application.Run() I
would not receive any events. (A rather sucky feature of .NET services I am
told).
Secondly, My ActiveX control is a server that simply pings me events in the
form of a byte array. I only ever create one instance of this object. The
event fires me what I assume to be an array of primitive types. I have also
made a sample app that uses a System.Windows.Form.Timer to fire events. This
passes a long value and this too leaks in service mode, so I am unsure if it
is anything to do with COM objects themselves, I am pretty certain there is
a leak with events.
Steve
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O4****************@TK2MSFTNGP10.phx.gbl... SPG,
I don't think that you should be calling Application.Run to establish the threading model of the thread that the code is running on. If
anything, I would create a new thread in the OnStart method, and then set the ApartmentState property of that thread to STA (or MTA, if you need it). Then, on that thread, you would perform your work.
Also, are you calling the static ReleaseComObject on the Marshal class to release all of your COM objects when you are done with them? You
should be aware that if one object you create exposes a property which exposes another COM object, then you have to call ReleaseComObject on that as
well. Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"SPG" <st*******************@nopoo.blueyonder.co.uk> wrote in message news:nL*********************@news-text.cableinet.net... Hi, We have a C# app that uis running as a service. It uses a third party activeX dll that we us to capture events. Because it is an activeX dll, we have to create our own message pump on
a thread (I Quite simple call application.run() on a new thread just after creatign eh activeX component)..
All this works fine, but we have noticed that we are getting quite a memory leak when running as a service.
Over the weekend, the application was running and this morning has consumed 300+ MB of ram. Normally sits in 5!
I have tried forcing GC every minute or so. This seems to help the situation a bit. Is there a known issue with ActiveX through interop and services?
Cheers,
Steve
SPG wrote...
[snip] Secondly, My ActiveX control is a server that simply pings me events in the form of a byte array. I only ever create one instance of this object. The event fires me what I assume to be an array of primitive types. I have also made a sample app that uses a System.Windows.Form.Timer to fire events. This passes a long value and this too leaks in service mode, so I am unsure if it is anything to do with COM objects themselves, I am pretty certain there is a leak with events. http://samgentile.com/blog/archive/2003/04/17/5797.aspx http://radio.weblogs.com/0111019/sto...onPointBasedEv
entHandlingBetweenComAndnet.html
Hi,
Although these were very interesting write-ups, as I said before, I am only
creating one object via com and that object then sends me events. Each event
was leaking about 8bytes per call in win service mode. as an app it was
fine.
Finally I solved the problem by setting my main service thread to be
[MTAThread], then spinning of the worker thread in STA mode. This thread
does the creation of the COM object, and once all is running nicely calls
Application.Run() on the same thread to set up the event sink.
This all works great and although not the cleanest solution, solves my prob.
Cheers,
Steve
"jerry" <je***@nospam.com> wrote in message
news:MP************************@msnews.microsoft.c om... SPG wrote... [snip] Secondly, My ActiveX control is a server that simply pings me events in
the form of a byte array. I only ever create one instance of this object.
The event fires me what I assume to be an array of primitive types. I have
also made a sample app that uses a System.Windows.Form.Timer to fire events.
This passes a long value and this too leaks in service mode, so I am unsure
if it is anything to do with COM objects themselves, I am pretty certain there
is a leak with events.
http://samgentile.com/blog/archive/2003/04/17/5797.aspx
http://radio.weblogs.com/0111019/sto...onPointBasedEv entHandlingBetweenComAndnet.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Maurice |
last post by:
Hi there,
I'm experiencing big memory problems on my webserver. First on an old
RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:
Linux version 2.4.20-4GB...
|
by: Vladimir |
last post by:
I created a windows service that performs a MSSQL2000 database analysis in a
separate threads with a specified interval. And when running this service
uses a lot of system memeory and it does...
|
by: bw |
last post by:
I have a basic custom collection that throws a new
exception if the item(key) is not found in the collection.
This is used as part of a calling function. It all works
correctly, the problem...
|
by: HeatherS |
last post by:
We are having issues with our windows services using memory and never
releasing it. We have one service that has a file watcher which takes an xml
file, inserts some records into a database, and...
|
by: Niron kag |
last post by:
Hi,
I have a windows service, which is currently installed, on my local computer.
The problem is that when I look at the task manager, I see that the “Mem
Usage”, become bigger and bigger....
|
by: anushrestha |
last post by:
I have a Windows Service written in C#. Memory used by the application based on the System.Environment.WorkingSet is 33MB at the begining. on average it goes up by 50MB every day. It reaches about...
|
by: Ryan Liu |
last post by:
Hi,
I use C# wrote an Client/Server application. In production environment, will
be 130 clients (Windows XP) connect to a Server (Windows 2000/2003 Server)
thought TCP/IP socket in a local 100M...
|
by: mariescottandeva |
last post by:
Hi,
I need to call an old C DLL from my Web Service. This in itself is
fine and I am able to do this no problem. My issue is that I need to
call the DLL thousands of times, and it has memory...
|
by: ertis6 |
last post by:
Hi all,
I need to calculate a value inside 8 nested for loops. 2 additional
for loops are used during calculation. It was working fine with 4
loops. My code is like this:
...
for(int i1=0;...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
| |