473,725 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory Leak

I am using VS2008.

I have a Windows Service application which creates Crystal Reports. This is
a multi theaded application which can run several reports at one time.
My problem - there is a memory leak someplace. I can not detect the memory
leak by running several reports by hand, but when I run tha app as a
servrice and process few hundred reports there is significant memory leak.
The application can consume over 1GB of memory where it should not go over
200 mb. I have few other applications that use Crystal Reports and those
applications do not have memory leak, the big difference is those
applications are single threaded.

My question is are there any free tools I can use to find the memory leak?

I have tried http://www.softprodigy.com but I could not get it to work it
just locks up.

Thank You
Peter
Jun 27 '08 #1
22 9350
Peter,

Always the first questions on Memory Leaks in the dotnet newsgroup

How do you know that there is a Memory Leak?

Cor

"Peter" <cz****@nospam. nospamschreef in bericht
news:OS******** ******@TK2MSFTN GP04.phx.gbl...
>I am using VS2008.

I have a Windows Service application which creates Crystal Reports. This
is a multi theaded application which can run several reports at one time.
My problem - there is a memory leak someplace. I can not detect the memory
leak by running several reports by hand, but when I run tha app as a
servrice and process few hundred reports there is significant memory leak.
The application can consume over 1GB of memory where it should not go over
200 mb. I have few other applications that use Crystal Reports and those
applications do not have memory leak, the big difference is those
applications are single threaded.

My question is are there any free tools I can use to find the memory leak?

I have tried http://www.softprodigy.com but I could not get it to work it
just locks up.

Thank You
Peter
Jun 27 '08 #2
Hi Peter ,

Regarding .Net memory leak issue, an important step is determing if it is a
managed leak or unmanaged memory leak.

Can you tell me what memory counter do you get "over 1G memory" result?
Windows has a lot of memory counters which may cause fake memory leak
conclusions. Basically, we should monitor "Process/Private Bytes"(or "VM
Size" column in task manager.) counter to determine memory leak. Note: we
should not use the "Mem Usage" column in task manager which is misleading.
I highly recommend you to download Process Explorer tool from the link
below since it is more powerful tool than task manager:
http://technet.microsoft.com/en-us/s.../bb896653.aspx

Once the "Private Bytes" is keeping increasing without decrease, it means
that the application is leaking memory. Now, you can monitor the ".Net CLR
Memory/# Bytes in all Heaps" counter. If the "Private Bytes" increases
while the ".Net CLR Memory" is stable, it indicates an unmanaged memory
leak. Otherwise, it basically means a managed memory leak. The article
below talks more information:
"I have a memory leak!!! What do i do? (defining the "where")"
http://blogs.msdn.com/tess/archive/2...leak-what-do-i
-do-defining-the-where.aspx

I will wait for your further feedback to determine if it is a managed or
unmanaged leak since they need totally different approach for
troubleshooting . Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #3

"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:19******** *************** ***********@mic rosoft.com...
Peter,

Always the first questions on Memory Leaks in the dotnet newsgroup

How do you know that there is a Memory Leak?

Cor

"Peter" <cz****@nospam. nospamschreef in bericht
news:OS******** ******@TK2MSFTN GP04.phx.gbl...
>>I am using VS2008.

I have a Windows Service application which creates Crystal Reports. This
is a multi theaded application which can run several reports at one time.
My problem - there is a memory leak someplace. I can not detect the
memory leak by running several reports by hand, but when I run tha app as
a servrice and process few hundred reports there is significant memory
leak. The application can consume over 1GB of memory where it should not
go over 200 mb. I have few other applications that use Crystal Reports
and those applications do not have memory leak, the big difference is
those applications are single threaded.

My question is are there any free tools I can use to find the memory
leak?

I have tried http://www.softprodigy.com but I could not get it to work it
just locks up.

Thank You
Peter
I do not know if it's the memory leak - that's what I am trying to find out.

The reason I am starting with this assumption is because when I look at the
"Mem Usage" in the Windows Task Manager the memory keeps growing and never
ever goes down and eventually the system goes to a craw until I restart the
application. Plus my other simullar applications when they run the "Mem
Usage" goes up and down and eventually goes back to the almost original
starting number when the applications is not processing anything.

Jun 27 '08 #4
I get "over 1G" on both "Mem Usage" and "VM Size", the VM Size is slightly
lower but it's consistant with "Mem Usage" so in this case "at least it
looks like Mem Usage is just as reliable"

I have also downlaoded the Process Exlprer and "Private Bytes" keep going up
and up, it does go down slightly at times but not as much as it goes up.
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:qL******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter ,

Regarding .Net memory leak issue, an important step is determing if it is
a
managed leak or unmanaged memory leak.

Can you tell me what memory counter do you get "over 1G memory" result?
Windows has a lot of memory counters which may cause fake memory leak
conclusions. Basically, we should monitor "Process/Private Bytes"(or "VM
Size" column in task manager.) counter to determine memory leak. Note: we
should not use the "Mem Usage" column in task manager which is misleading.
I highly recommend you to download Process Explorer tool from the link
below since it is more powerful tool than task manager:
http://technet.microsoft.com/en-us/s.../bb896653.aspx

Once the "Private Bytes" is keeping increasing without decrease, it means
that the application is leaking memory. Now, you can monitor the ".Net CLR
Memory/# Bytes in all Heaps" counter. If the "Private Bytes" increases
while the ".Net CLR Memory" is stable, it indicates an unmanaged memory
leak. Otherwise, it basically means a managed memory leak. The article
below talks more information:
"I have a memory leak!!! What do i do? (defining the "where")"
http://blogs.msdn.com/tess/archive/2...leak-what-do-i
-do-defining-the-where.aspx

I will wait for your further feedback to determine if it is a managed or
unmanaged leak since they need totally different approach for
troubleshooting . Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #5
Hi Peter,

Thanks for your feedback.

This should mean a memory leak in your application. Then, have you checked
".Net CLR Memory/# Bytes in all Heaps" counter? It will help us to
distinguish between managed/unmanaged leak in the application.

The "Mem Usage" actually means the "Working Set Size" which is the physical
RAM that a process currently uses instead of virtual memory. In modern
Virtual Memory OS, the physical RAM usage normally makes no sense to
application developer since the kernel VMM manages this. The "Working Set"
increases/decreases based on the OS paging activities and the process
working set commit. For example, if you bring a GUI application to the
foreground, it "Mem Usage" will go up immediately while many other
background applications' "Mem Usage" may decrease. This has nothing to do
with the memory leak. Also, although one applicatin is leaking memory, if
it has reached the "Working Set" charge limit, you will find that "Mem
Usage" not change anymore, but the process is still leaking. So, "Mem
Usage" is basically a useless counter.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== ===========
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #6
The Private Bytes counter - Keeps increasing
The # Bytes in all Heaps - Keeps increasing
Gen 0 heap size - is stable (increases and decreases)
Gen 1 heap size - is stable (increases and decreases)
Gen 2 heap size - Keeps increasing

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:Sx******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter,

Thanks for your feedback.

This should mean a memory leak in your application. Then, have you checked
".Net CLR Memory/# Bytes in all Heaps" counter? It will help us to
distinguish between managed/unmanaged leak in the application.

The "Mem Usage" actually means the "Working Set Size" which is the
physical
RAM that a process currently uses instead of virtual memory. In modern
Virtual Memory OS, the physical RAM usage normally makes no sense to
application developer since the kernel VMM manages this. The "Working Set"
increases/decreases based on the OS paging activities and the process
working set commit. For example, if you bring a GUI application to the
foreground, it "Mem Usage" will go up immediately while many other
background applications' "Mem Usage" may decrease. This has nothing to do
with the memory leak. Also, although one applicatin is leaking memory, if
it has reached the "Working Set" charge limit, you will find that "Mem
Usage" not change anymore, but the process is still leaking. So, "Mem
Usage" is basically a useless counter.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== ===========
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #7
Hi Peter,

Thanks for your feedback.

Ok, this sounds like a managed memory leak in .Net.

To troubleshoot the managed memory leak, we normally use windbg+SOS.dll
extension which understands the internal data structure of .Net objects.
The basic idea is: first dumping all the managed objects on the managed
heap sorted by size. Then we can understand what type of object costs the
most of memory(which is the possible culprit for leaking). Then, we can use
"!gcroot" command to traverse all the root graph to find the call graph
that is holding the reference to the leaking objects. The articles talk
about the detailed steps regarding how to perform these steps:
"Tracking down managed memory leaks (how to find a GC leak)"
http://blogs.msdn.com/ricom/archive/...10/279612.aspx
".NET Memory Leak Case Study: The Event Handlers That Made The Memory
Baloon"
http://blogs.msdn.com/tess/archive/2...case-study-the
-event-handlers-that-made-the-memory-baloon.aspx

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== ===========
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #8
I've downloaded vadump.exe from Microsoft but I am getting error
'FAILURE query working set 24' when I run it.
and
Where can I find these tools like !dumpheap and !eeheap

I have VS2008 Archtect addition installed on my machine, but I don't have
those programs.

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:Tg******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter,

Thanks for your feedback.

Ok, this sounds like a managed memory leak in .Net.

To troubleshoot the managed memory leak, we normally use windbg+SOS.dll
extension which understands the internal data structure of .Net objects.
The basic idea is: first dumping all the managed objects on the managed
heap sorted by size. Then we can understand what type of object costs the
most of memory(which is the possible culprit for leaking). Then, we can
use
"!gcroot" command to traverse all the root graph to find the call graph
that is holding the reference to the leaking objects. The articles talk
about the detailed steps regarding how to perform these steps:
"Tracking down managed memory leaks (how to find a GC leak)"
http://blogs.msdn.com/ricom/archive/...10/279612.aspx
".NET Memory Leak Case Study: The Event Handlers That Made The Memory
Baloon"
http://blogs.msdn.com/tess/archive/2...case-study-the
-event-handlers-that-made-the-memory-baloon.aspx

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== ===========
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #9
Hi Peter,

Thanks for your feedback.

Actually, there is no need to run vadump.exe because we have used different
counters from Process Explorer to confirm the memory leak. So we may ignore
the first 3 steps in the link below and start from the step 4:
http://blogs.msdn.com/ricom/archive/...10/279612.aspx

!dumpheap and !eeheap are both the windbg extension commands exported by
SOS.dll which is written by the CLR team for internal debugging purpose.
So, we need to install windbg to debug this memory leak instead of using VS
debugger. Yes, we can use VS debugger with SOS.dll, but it is inconvenient.
The link below talks about how to use VS debugger+SOS.dl l for .Net
debugging:
".NET Finalizer Memory Leak: Debugging with sos.dll in Visual Studio"
http://blogs.msdn.com/tess/archive/2...mory-leak-debu
gging-with-sos-dll-in-visual-studio.aspx

I prefer windbg because it is more powerful and convenient for production
debugging than VS debugger and it is free. If you have never used windbg
before, you can follow the basic setup in the blog I written below:
"How to debug application crash/hang in production environment"
http://blogs.msdn.com/msdnts/archive...pplication-cra
sh-hang-in-production-environment.asp x

After completing the windbg installation and configuration, you can follow
to start from "Step 4: Attach Windbg and load SOS" in the first blog link
above.

If there is anything unclear, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== ===========
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3412
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? In nut shell, what is/are the realtion/s between the Memory Leak and Memory Corruption. Juts Theoritical Assumtion below:
17
4809
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is easier to reproduce (e.g.: remote machine not available). After about 1 day, I get a usage of 300MB of memory. I have used .NET Memory Profiler tool to try to see where the leak is located. For all the leaky instances, I can see the following (I...
4
6088
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password"; scope.Path.Path=@"\\pc\root\cimv2";
20
8115
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex matches are called within a loop (like if or for). E.g. for(int i = 0; i < 10; i++) { Regex r = new Regex();
23
4557
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
8
8549
by: Adrian | last post by:
Hi I have a JS program that runs localy (under IE6 only) on a PC but it has a memory leak (probably the known MS one!) What applications are there that I could use to look at the memory usage of each object within my JS app to help locate my problem? Thanks
7
6935
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports the status of the machines. Upon we follow the .NET object lifetime recommendations the application is constantly consuming more memory! The problem is on the ManagementObjectSearch, upon we Dispose the object it seems that is not releasing the...
3
5324
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?
7
15711
by: Ragnar Agustsson | last post by:
Hi all I have been wandering about the best way to sandbox memory leaks in 3rd party libraries when using them from the .Net framework. I have a 3rd party library, written in C++, that leaks a lot of memory but I still had to use it. 1. After using DLLImport and seeing the memory leak I tried to load and
0
8888
marktang
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...
0
9401
Oralloy
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...
1
9176
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,...
0
8097
agi2029
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...
1
6702
isladogs
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...
0
6011
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();...
0
4519
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...
1
3221
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
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.