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 3143
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 ReleaseComObjec t 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 ReleaseComObjec t on that as well.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"SPG" <st************ *******@nopoo.b lueyonder.co.uk > wrote in message
news:nL******** *************@n ews-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 ReleaseComObjec t 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.Applicati on xlApp = new Excel.Applicati on();
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.Applicati on,
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.c om> wrote in
message news:O4******** ********@TK2MSF TNGP10.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 ReleaseComObjec t 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 ReleaseComObjec t on that as
well. Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"SPG" <st************ *******@nopoo.b lueyonder.co.uk > wrote in message news:nL******** *************@n ews-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
entHandlingBetw eenComAndnet.ht ml
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.c om> wrote in message
news:MP******** *************** *@msnews.micros oft.com... 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 entHandlingBetw eenComAndnet.ht ml 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 (root@Pentium.suse.de) (gcc version 3.3
20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003
Apache 1.3.27-41
PHP 4.3.1-52
MySQL 3.23.55-20
|
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 release it after finishing it's
jobs and starting to "sleep". I use there Microsoft.AplicationBlocks.Data
libary to access database and I suppose the service caches the data since it
performs all the next parcings at a moment unlike at the first time...
|
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 (discovered using a memory
profiler) is that the base exception being thrown in the
collection is not being disposed of.
I understand about the GC etc etc. It appears that
something is hanging on to a reference to System.Exception
and a...
|
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 creates a bunch of PDFs with
Crystal Reports. Another service is a remote object which serves as our data
access component -- basically it just executes stored procedures and returns
datasets. If you watch the services in task manager, you can...
|
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.
Has someone any idea why this happens?
Anyway to solve this problem I thought to stop the service and start it
programmatically when it’s “Mem Usage” is too big.
Is it possible?
| |
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 700MB in about 14 days.
So to maintain the memory used by the application low, i have to restart the service. once i restart the service the memory used by the application changed to 33MB again.
I tried my best to clean up any resource i used on...
|
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 LAN. "Server" is running as a Windows
service. The is one thread running for one clinet in the server.
Sometime the user tells me the Sever will be slow after it runs for 1-2
days.
|
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 leak and memory
corruption problems, so after a while it dies with a memory corruption
error. I donot have the option of fixing the memory leak, so I need
to come up with a solution.
my understanding is is the once an external dll is imported...
|
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; i1<x1; i1 = i1++){
...
for(int i2=0; i2<x2; i2 = i2++){
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |