I've got a Windows Service written in C# that is having some
unfortunate memory issues. I've been working with .NET MemProfiler and
AllocationProfiler. But you don't have to use those programs to notice
the memory leak. The memory usage in the TaskManager for the process
can be seen climbing and climbing, MBs at a time.
When using MemProfiler, I noticed the Win32 Heap is what seems to be
growing. I've been searching on the internet for Win32 Heap references
but I haven't found much. So what I'm asking is does anyone have some
links to explain on a .NET service interacts with this heap and why it
would get so large?
As a side note, MemProfilers is also reporting that my String instances
are the most troublesome. I'm using them like I would in a regular
application, nothing unordinary. Could some of my memory issues be
related to the timer_elasped event which might be hold reference to my
objects? I don't dispose the timer because, well, I kinda need it ;)
Thanks for any help.
Also, I'm using the WMI a lot. I've heard memory leaks have been
associated with the Management Object but also can't find anything
really on this.
*Really sorry if this is a double post* 5 2663
<Ro**********@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
| I've got a Windows Service written in C# that is having some
| unfortunate memory issues. I've been working with .NET MemProfiler and
| AllocationProfiler. But you don't have to use those programs to notice
| the memory leak. The memory usage in the TaskManager for the process
| can be seen climbing and climbing, MBs at a time.
|
Note that you should use perfmon to monitor memory consumption.
| When using MemProfiler, I noticed the Win32 Heap is what seems to be
| growing. I've been searching on the internet for Win32 Heap references
| but I haven't found much. So what I'm asking is does anyone have some
| links to explain on a .NET service interacts with this heap and why it
| would get so large?
|
Services are just like any other managed applications, they don't interact
with the managed heap in a different fashion.
Probably your memory consumption relates to unmanaged heap growth, again use
the perfmon and watch your managed (Gen0, 1 and 2) GC heap counters.
| As a side note, MemProfilers is also reporting that my String instances
| are the most troublesome.
What exactly do you mean with troublesome?
I'm using them like I would in a regular
| application, nothing unordinary.
So, they are troublesome too?
Could some of my memory issues be
| related to the timer_elasped event which might be hold reference to my
| objects? I don't dispose the timer because, well, I kinda need it ;)
|
| Thanks for any help.
|
| Also, I'm using the WMI a lot. I've heard memory leaks have been
| associated with the Management Object but also can't find anything
| really on this.
|
If this is the cause of the leak, you should be able to identify them with
the profiler, right?.
What kind if WMI objects are you using in your code, do you dispose the
Management objects when done?
Do you connect to external system?
What version of the framework are you running?
Really sorry for the large amount of questions, but we can't help you
without your answers :-)
Willy.
Thanks for your input, everyone. I've reviewed all your posts and will
now apply some of your thoughts to my problem. To quickly answer, yes
I am using the SciTech Mem Profiler. It's been some help but I'm also
trying out the perfmon to look at my heaps.
I am using Management Objects and I do dispose everything. I have a
custom made class that I use to fill with data and serialize to an XML
file. I also do de-serialization as well further on in the service.
All my streams are disposed using the Close() method.
Without going into to much detail, I have a global declaration of my
custom class. The service then will invoke a method that will then
create a new instance of it using MyClass mc = new MyClass(). After
the service has worked with the class, I then set it to null which as I
thought would tell the GC that this is ready to be collected. But with
the MemProfiler, I see the instances of this class increasing every
timer elasped event. So obviously it's not getting cleaned up because
there is a reference somewhere. Possibly with that global declaration?
Again I will apply everyone's thoughts to the best that I can and
hopefully have something a bit more clear. Thanks again for looking
and helping!
Willy Denoyette [MVP] wrote:
<Ro**********@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
| I've got a Windows Service written in C# that is having some
| unfortunate memory issues. I've been working with .NET MemProfiler and
| AllocationProfiler. But you don't have to use those programs to notice
| the memory leak. The memory usage in the TaskManager for the process
| can be seen climbing and climbing, MBs at a time.
|
Note that you should use perfmon to monitor memory consumption.
| When using MemProfiler, I noticed the Win32 Heap is what seems to be
| growing. I've been searching on the internet for Win32 Heap references
| but I haven't found much. So what I'm asking is does anyone have some
| links to explain on a .NET service interacts with this heap and why it
| would get so large?
|
Services are just like any other managed applications, they don't interact
with the managed heap in a different fashion.
Probably your memory consumption relates to unmanaged heap growth, again use
the perfmon and watch your managed (Gen0, 1 and 2) GC heap counters.
| As a side note, MemProfilers is also reporting that my String instances
| are the most troublesome.
What exactly do you mean with troublesome?
I'm using them like I would in a regular
| application, nothing unordinary.
So, they are troublesome too?
Could some of my memory issues be
| related to the timer_elasped event which might be hold reference to my
| objects? I don't dispose the timer because, well, I kinda need it ;)
|
| Thanks for any help.
|
| Also, I'm using the WMI a lot. I've heard memory leaks have been
| associated with the Management Object but also can't find anything
| really on this.
|
If this is the cause of the leak, you should be able to identify them with
the profiler, right?.
What kind if WMI objects are you using in your code, do you dispose the
Management objects when done?
Do you connect to external system?
What version of the framework are you running?
Really sorry for the large amount of questions, but we can't help you
without your answers :-)
Willy.
<Ro**********@gmail.comwrote:
Without going into to much detail, I have a global declaration of my
custom class. The service then will invoke a method that will then
create a new instance of it using MyClass mc = new MyClass(). After
the service has worked with the class, I then set it to null which as I
thought would tell the GC that this is ready to be collected. But with
the MemProfiler, I see the instances of this class increasing every
timer elasped event.
The Scitech Profiler is ideal for tracking this down.
On the initial screen, double-click on one of the instances that should be
"gone". This will take you to the next tab, and here you can look at the
root paths for the object. This will tell you *exactly* who is still holding
references to it. Eliminate these references, and you're good to go.
Possibly with that global declaration?
Depends on how you implemented it.
For me, in C#, I've had a number of problems like that that all boiled down
to me registering an event handler, and then not removing it. Because the
event handler stayed registered, the instance it was referring to stayed
around forever and we leaked memory like a sieve.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise http://www.coversant.net/blogs/cmullins
Ok, I was able to iron out the memory leak caused by my own personal
class. MemProfiler is reporting that my string instances,
IdentifierChangedEventHandler and other various System instances
(System.Management, System.Collections, etc) are not getting cleaned
up. So i've got some more work to do. But I've got a better idea how
to work with MemProfiler so thank you for that.
Chris Mullins wrote:
<Ro**********@gmail.comwrote:
Without going into to much detail, I have a global declaration of my
custom class. The service then will invoke a method that will then
create a new instance of it using MyClass mc = new MyClass(). After
the service has worked with the class, I then set it to null which as I
thought would tell the GC that this is ready to be collected. But with
the MemProfiler, I see the instances of this class increasing every
timer elasped event.
The Scitech Profiler is ideal for tracking this down.
On the initial screen, double-click on one of the instances that should be
"gone". This will take you to the next tab, and here you can look at the
root paths for the object. This will tell you *exactly* who is still holding
references to it. Eliminate these references, and you're good to go.
Possibly with that global declaration?
Depends on how you implemented it.
For me, in C#, I've had a number of problems like that that all boiled down
to me registering an event handler, and then not removing it. Because the
event handler stayed registered, the instance it was referring to stayed
around forever and we leaked memory like a sieve.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise http://www.coversant.net/blogs/cmullins
Well, I've tried over and over and cannot reduce my string instance
count. It's like it never gets collected. I hope Monday goes a little
better. If anyone has experience with string instances and them not
being GCed, please let me know. Ro**********@gmail.com wrote:
Ok, I was able to iron out the memory leak caused by my own personal
class. MemProfiler is reporting that my string instances,
IdentifierChangedEventHandler and other various System instances
(System.Management, System.Collections, etc) are not getting cleaned
up. So i've got some more work to do. But I've got a better idea how
to work with MemProfiler so thank you for that.
Chris Mullins wrote:
<Ro**********@gmail.comwrote:
Without going into to much detail, I have a global declaration of my
custom class. The service then will invoke a method that will then
create a new instance of it using MyClass mc = new MyClass(). After
the service has worked with the class, I then set it to null which as I
thought would tell the GC that this is ready to be collected. But with
the MemProfiler, I see the instances of this class increasing every
timer elasped event.
The Scitech Profiler is ideal for tracking this down.
On the initial screen, double-click on one of the instances that should be
"gone". This will take you to the next tab, and here you can look at the
root paths for the object. This will tell you *exactly* who is still holding
references to it. Eliminate these references, and you're good to go.
Possibly with that global declaration?
Depends on how you implemented it.
For me, in C#, I've had a number of problems like that that all boiled down
to me registering an event handler, and then not removing it. Because the
event handler stayed registered, the instance it was referring to stayed
around forever and we leaked memory like a sieve.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise http://www.coversant.net/blogs/cmullins This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tron Thomas |
last post by:
Given the following information about memory management in C++:
-----
The c-runtime dynamic memory manager (and most other commercial memory
managers) has issues with fragmentation similar to a...
|
by: Franklin Lee |
last post by:
Hi All,
I use new to allocate some memory,even I doesn't use delete to release them.
When my Application exit, OS will release them.
Am I right?
If I'm right, how about Thread especally on...
|
by: ~Gee |
last post by:
Hi Folks!
Please see the program below:
1 #include<iostream>
2 #include<list>
3 #include <unistd.h>
4 using namespace std;
5 int main()
6 {
7 {
|
by: DANIEL BEAULIEU J |
last post by:
Basically i am a student taking an operating systems course which
is c++ intensive. Familiar with Java, and so not so familiar with memory
management. Looking for suggestions of exercises or web...
|
by: Mike P |
last post by:
I know everything about reference counting and making sure you don't have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but...
| |
by: beattie.stuart |
last post by:
I think I've found a memory leak trying to use the
system.management.ManagementObject, but it could be my programming
skills so I'd appreciate some advice. I've writing a monitoring routine
that...
|
by: smnoff |
last post by:
I have searched the internet for malloc and dynamic malloc; however, I still
don't know or readily see what is general way to allocate memory to char *
variable that I want to assign the substring...
|
by: Jim Land |
last post by:
Jack Slocum claims here
http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript-
memory-leaks/
that "almost every site you visit that uses JavaScript is leaking memory".
...
|
by: kumarmdb2 |
last post by:
Hi guys,
For last few days we are getting out of private memory error. We have a
development environment. We tried to figure out the problem but we
believe that it might be related to the OS...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
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: 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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
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...
| |