I've got a Windows Service written in C# that is having some
unfortunate memory issues. I've been working with .NET MemProfiler and
AllocationProfi ler. 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 2678
<Ro**********@g mail.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.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
| AllocationProfi ler. 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**********@g mail.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.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
| AllocationProfi ler. 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**********@g mail.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,
IdentifierChang edEventHandler and other various System instances
(System.Managem ent, System.Collecti ons, 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**********@g mail.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**********@gm ail.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,
IdentifierChang edEventHandler and other various System instances
(System.Managem ent, System.Collecti ons, 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**********@g mail.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 hard drive file
system.
Over time, the more often use call new/delete or alloc/free, there
will be
gaps and fragments in the heap. This can lead to inefficient use of
available memory, as well as cache-hit inefficiencies.
|
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 Solaries OS?
This means that I use new to allocate memory in one Thread and doesn't use
delete to release them.
|
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 resources to help
me become familiar with pointers and referencing etc. Thank you.
|
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 not necessary give it back to
the OS.
It seems that .NET win app will only return memory to the OS when the OS is
asking for it. But!!! When the OS is asking for it is usually too late, tons
of swapping and slow performance.
| |
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 queries WMI for some stats, but it continually eats into memory.
I've cut the code down to the following sample but the problem is still
there:
Imports System
Imports System.Management
|
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 that I found inside of a
string.
Any ideas?
|
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".
Anybody know anything about this?
Does *Javascript* leak memeory, or
does the *browser* leak 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 (I am new to Windows so not
sure). We are currently bouncing the instance to overcome this error. This
generally happen at the end of business day only (So maybe memory
might be getting used up?). We have already increased the statement heap &
...
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |