473,473 Members | 4,297 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

multithreaded tcp/ip server large page file

cj
I have a 2005 TCP/IP server that creates a new thread to handle each
incoming TCP/IP request. Once the request has been answered by the
thread the TCP/IP socket is disconnected and the sub/thread ends. This
program originally written in 2003 and I rewrote it in 2005 earlier this
year. I don't know how long this has been going on but we just noticed
today that the program was using over a gig of virtual memory. Real
memory was quite low. The program had been running about 2 weeks.
Shutting it down and restarting it dropped the virtual memory to almost
nothing.

I don't know what causes this problem but I've always wondered about the
threads that end not being cleaned up. I use thread.start to start them
but nothing to end them. I've been told VB will clean these up.

One thing that didn't change over from 2003 to 2005 was
Thread.ApartmentState = ApartmentState.STA. 2005 says it obsolete but
the program runs so I ignored it's warning. Could this be causing a
problem?

Any ideas?
Jun 4 '07 #1
39 2811
cj
My research suggest that there is no end thread type statement
necessary--just like I've been told. When the sub that comprises my
thread ends the thread ends. As ApartmentState.STA is obsolete but not
illegal I doubt it is causing virtual memory to grow. What else could
it be?

cj wrote:
I have a 2005 TCP/IP server that creates a new thread to handle each
incoming TCP/IP request. Once the request has been answered by the
thread the TCP/IP socket is disconnected and the sub/thread ends. This
program originally written in 2003 and I rewrote it in 2005 earlier this
year. I don't know how long this has been going on but we just noticed
today that the program was using over a gig of virtual memory. Real
memory was quite low. The program had been running about 2 weeks.
Shutting it down and restarting it dropped the virtual memory to almost
nothing.

I don't know what causes this problem but I've always wondered about the
threads that end not being cleaned up. I use thread.start to start them
but nothing to end them. I've been told VB will clean these up.

One thing that didn't change over from 2003 to 2005 was
Thread.ApartmentState = ApartmentState.STA. 2005 says it obsolete but
the program runs so I ignored it's warning. Could this be causing a
problem?

Any ideas?
Jun 4 '07 #2
Well, handling a request with a new thread is a pretty bad way to ago.

Each time you spin up a new thread, it's going to take up at least 1 meg of
fully committed virtual memory. You can read all the gory details about this
at:
http://www.bluebytesoftware.com/blog...ed0f97ab5.aspx

You really, really need to use a different model is you want your
application to scale in any meaningful way. Async I/O is really your only
long term solution.

Typically, you don't need to shutdown threads - they just go away when their
top level method exits. If you poke at your application, use a Performance
Counter to tell how many threads you've got running. If the number is very
high, then something is keeping the threads heald open. Do NOT (don't!
really!) just call "Kill Thread" on the open threads if this is the case -
figure out what the problem is and fix it.

You don't need to worry about the Apartment state stuff - it's not relevant
for a socket app.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins

"cj" <cj@nospam.nospamwrote in message
news:OJ**************@TK2MSFTNGP05.phx.gbl...
>I have a 2005 TCP/IP server that creates a new thread to handle each
incoming TCP/IP request. Once the request has been answered by the thread
the TCP/IP socket is disconnected and the sub/thread ends. This program
originally written in 2003 and I rewrote it in 2005 earlier this year. I
don't know how long this has been going on but we just noticed today that
the program was using over a gig of virtual memory. Real memory was quite
low. The program had been running about 2 weeks. Shutting it down and
restarting it dropped the virtual memory to almost nothing.

I don't know what causes this problem but I've always wondered about the
threads that end not being cleaned up. I use thread.start to start them
but nothing to end them. I've been told VB will clean these up.

One thing that didn't change over from 2003 to 2005 was
Thread.ApartmentState = ApartmentState.STA. 2005 says it obsolete but the
program runs so I ignored it's warning. Could this be causing a problem?

Any ideas?

Jun 4 '07 #3
Hi cj,
This issue might be caused by creating a new thread to handle each incoming
request since one new thread will consume 1MB virtual memory. You may
consider to use Thread Pool to redesign your application. I would like to
provide the following articles here for your reference:
Programming the Thread Pool in the .NET Framework
http://msdn2.microsoft.com/en-us/library/ms973903.aspx
The Managed Thread Pool
http://msdn2.microsoft.com/en-us/library/0ka9477y.aspx

Hope this helps. Please feel free to let us know if you have any other
questions or concerns.
Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 5 '07 #4
cj
Is this 1MB of virtual memory released when the thread ends?

I'd like to see some documentation on the statement that each new thread
consumes 1MB virtual memory. If you can point me to an article I'd
appreciate it.
Charles Wang[MSFT] wrote:
Hi cj,
This issue might be caused by creating a new thread to handle each incoming
request since one new thread will consume 1MB virtual memory. You may
consider to use Thread Pool to redesign your application. I would like to
provide the following articles here for your reference:
Programming the Thread Pool in the .NET Framework
http://msdn2.microsoft.com/en-us/library/ms973903.aspx
The Managed Thread Pool
http://msdn2.microsoft.com/en-us/library/0ka9477y.aspx

Hope this helps. Please feel free to let us know if you have any other
questions or concerns.
Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 5 '07 #5
How weird. I wrote up a full reply, and I see it on Google, but not here:
http://groups.google.com/group/micro...9c7a2df42f27a6

Anyway, the original reply was:

Well, handling a request with a new thread is a pretty bad way to ago.

Each time you spin up a new thread, it's going to take up at least 1 meg of
fully committed virtual memory. You can read all the gory details about this
at:
http://www.bluebytesoftware.com/blog...d7537-f982-488...
You really, really need to use a different model is you want your
application to scale in any meaningful way. Async I/O is really your only
long term solution.
Typically, you don't need to shutdown threads - they just go away when their
top level method exits. If you poke at your application, use a Performance
Counter to tell how many threads you've got running. If the number is very
high, then something is keeping the threads heald open. Do NOT (don't!
really!) just call "Kill Thread" on the open threads if this is the case -
figure out what the problem is and fix it.
You don't need to worry about the Apartment state stuff - it's not relevant
for a socket app.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
"cj" <cj@nospam.nospamwrote in message
news:uK**************@TK2MSFTNGP06.phx.gbl...
Is this 1MB of virtual memory released when the thread ends?

I'd like to see some documentation on the statement that each new thread
consumes 1MB virtual memory. If you can point me to an article I'd
appreciate it.
Charles Wang[MSFT] wrote:
>Hi cj,
This issue might be caused by creating a new thread to handle each
incoming request since one new thread will consume 1MB virtual memory.
You may consider to use Thread Pool to redesign your application. I would
like to provide the following articles here for your reference:
Programming the Thread Pool in the .NET Framework
http://msdn2.microsoft.com/en-us/library/ms973903.aspx
The Managed Thread Pool
http://msdn2.microsoft.com/en-us/library/0ka9477y.aspx

Hope this helps. Please feel free to let us know if you have any other
questions or concerns.
Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================= ====
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check
box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly. 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.
================================================= ===== When responding to
posts, please "Reply to Group" via your newsreader so that others may
learn and benefit from this issue.
================================================= =====
This posting is provided "AS IS" with no warranties, and confers no
rights. ================================================== ====

Jun 5 '07 #6
Hi cj,
How did you end your thread? Generally if a thread handle is closed, the
related virtual memory will be released.
I recommend that you use Process Explorer to monitor your application to
check if the threads handles were closed after they ended.
You can download the tool from:
http://www.microsoft.com/technet/sys...sExplorer.mspx

Open Process Explorer, click View->Show Lower Panel, select Lower Panel
View-Handles.

You may check if the thread number is growing and the handles are not
closed.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 6 '07 #7
cj
I'll spare you all the details but it's started from the class
"sessionclass" which has only one sub "ThreadMain" like this:

Dim oSession As SessionClass
Dim oThread As Thread
oThread = New Thread(AddressOf oSession.ThreadMain)
oThread.Start()

It's my understanding that when the sub ThreadMain ends the tread also
ends. This is true right? I have not heard of closing a thread handle.

The first thing that ThreadMain does is increment a counter and the last
thing is decrement the counter. The counter is another class which uses
synclock to keep the threads from conflicting with eachother. This
counter is read an displayed by a timer in the main program to show how
many threads are running at any given time. It usually runs between 1
and 3. Part of the processing being done by each thread is contacting a
sql server and if the sql server is having problems processing by this
program backs up and I've seen it with over 100 threads open before. It
handles it fine as the sql request time out this program returns and
error response to the TCP/IP client that the thread is handling and the
sub/tread ends. It just takes much longer to timeout than to get a
response from SQL most of the time so during those times the concurrent
thread count will be much higher.
Charles Wang[MSFT] wrote:
Hi cj,
How did you end your thread? Generally if a thread handle is closed, the
related virtual memory will be released.
I recommend that you use Process Explorer to monitor your application to
check if the threads handles were closed after they ended.
You can download the tool from:
http://www.microsoft.com/technet/sys...sExplorer.mspx

Open Process Explorer, click View->Show Lower Panel, select Lower Panel
View-Handles.

You may check if the thread number is growing and the handles are not
closed.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 6 '07 #8
cj
I'll spare you all the details but it's started from the class
"sessionclass" which has only one sub "ThreadMain" like this:

Dim oSession As SessionClass
Dim oThread As Thread
oThread = New Thread(AddressOf oSession.ThreadMain)
oThread.Start()

It's my understanding that when the sub ThreadMain ends the tread also
ends. This is true right? I have not heard of closing a thread handle.

The first thing that ThreadMain does is increment a counter and the last
thing is decrement the counter. The counter is another class which uses
synclock to keep the threads from conflicting with eachother. This
counter is read an displayed by a timer in the main program to show how
many threads are running at any given time. It usually runs between 1
and 3. Part of the processing being done by each thread is contacting a
sql server and if the sql server is having problems processing by this
program backs up and I've seen it with over 100 threads open before. It
handles it fine as the sql request time out this program returns and
error response to the TCP/IP client that the thread is handling and the
sub/tread ends. It just takes much longer to timeout than to get a
response from SQL most of the time so during those times the concurrent
thread count will be much higher.
Charles Wang[MSFT] wrote:
Hi cj,
How did you end your thread? Generally if a thread handle is closed, the
related virtual memory will be released.
I recommend that you use Process Explorer to monitor your application to
check if the threads handles were closed after they ended.
You can download the tool from:
http://www.microsoft.com/technet/sys...sExplorer.mspx

Open Process Explorer, click View->Show Lower Panel, select Lower Panel
View-Handles.

You may check if the thread number is growing and the handles are not
closed.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 6 '07 #9
cj
I'll spare you all the details but it's started from the class
"sessionclass" which has only one sub "ThreadMain" like this:

Dim oSession As SessionClass
Dim oThread As Thread
oThread = New Thread(AddressOf oSession.ThreadMain)
oThread.Start()

It's my understanding that when the sub ThreadMain ends the tread also
ends. This is true right? I have not heard of closing a thread handle.

The first thing that ThreadMain does is increment a counter and the last
thing is decrement the counter. The counter is another class which uses
synclock to keep the threads from conflicting with eachother. This
counter is read an displayed by a timer in the main program to show how
many threads are running at any given time. It usually runs between 1
and 3. Part of the processing being done by each thread is contacting a
sql server and if the sql server is having problems processing by this
program backs up and I've seen it with over 100 threads open before. It
handles it fine as the sql request time out this program returns and
error response to the TCP/IP client that the thread is handling and the
sub/tread ends. It just takes much longer to timeout than to get a
response from SQL most of the time so during those times the concurrent
thread count will be much higher.

Charles Wang[MSFT] wrote:
Hi cj,
How did you end your thread? Generally if a thread handle is closed, the
related virtual memory will be released.
I recommend that you use Process Explorer to monitor your application to
check if the threads handles were closed after they ended.
You can download the tool from:
http://www.microsoft.com/technet/sys...sExplorer.mspx

Open Process Explorer, click View->Show Lower Panel, select Lower Panel
View-Handles.

You may check if the thread number is growing and the handles are not
closed.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 6 '07 #10
cj
Thank you for your response. It's always been my belief that everyone
is free to have their own opinions on what is a good or bad way to write
a program and I respect your opinion, however from where I stand this is
indeed an entirely appropriate way to complete the task at hand.

The 1 meg of fully committed virtual memory the threads use should not
be kept after the threads end according to what I've seen/read. And if
I'm right then letting each thread have a meg is no problem.
Chris Mullins [MVP] wrote:
How weird. I wrote up a full reply, and I see it on Google, but not here:
http://groups.google.com/group/micro...9c7a2df42f27a6

Anyway, the original reply was:

Well, handling a request with a new thread is a pretty bad way to ago.

Each time you spin up a new thread, it's going to take up at least 1 meg of
fully committed virtual memory. You can read all the gory details about this
at:
http://www.bluebytesoftware.com/blog...d7537-f982-488...
You really, really need to use a different model is you want your
application to scale in any meaningful way. Async I/O is really your only
long term solution.
Typically, you don't need to shutdown threads - they just go away when their
top level method exits. If you poke at your application, use a Performance
Counter to tell how many threads you've got running. If the number is very
high, then something is keeping the threads heald open. Do NOT (don't!
really!) just call "Kill Thread" on the open threads if this is the case -
figure out what the problem is and fix it.
You don't need to worry about the Apartment state stuff - it's not relevant
for a socket app.

Jun 6 '07 #11
Hi cj,
Yes, your understanding is right. When the sub treadmain ends, the thread
also ends. Just not sure if your server has a heavy load of requests and a
single request handling finishes in a long time, in other words, your
server might work in a very busy condition. Although some threads were
released, new threads were generated. The speed of creating new thread was
faster than the speed of releasing old thread.

I recommend that you run perfmon.exe to monitor the counter "Thread Count"
and "Virtual Bytes" of your process to see if this issue was caused by
thread explosion.

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 7 '07 #12
cj
I'd like to use perfmon but I can't find anything in it. It's too much
info. Where do I find "Thread Count" and "Virtual Bytes"?

I go to the bottom and right click then add counters and can't figure
out what to add. I think I need to set performance object to .net clr
memory but then which items under that do I monitor? I can't find
anywhere to monitor how many threads are running. In task manager I am
monitoring threads running and virtual memory.

I don't have a clue what I'm looking at in perfmon.
Charles Wang[MSFT] wrote:
Hi cj,
Yes, your understanding is right. When the sub treadmain ends, the thread
also ends. Just not sure if your server has a heavy load of requests and a
single request handling finishes in a long time, in other words, your
server might work in a very busy condition. Although some threads were
released, new threads were generated. The speed of creating new thread was
faster than the speed of releasing old thread.

I recommend that you run perfmon.exe to monitor the counter "Thread Count"
and "Virtual Bytes" of your process to see if this issue was caused by
thread explosion.

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====
Jun 7 '07 #13
Hi cj,
Please refer to the following steps to add the counters:
1. Run perfmon.exe from command prompt;
2. Delete the original counters by clicking DELETE key on keyboard;
2. Click Add to add counters;
3. Select Process in the Performance object list;
4. Select your process name in the list of "Select instances from list";
5. Add Thread Count and Virtual Bytes from the list "Select counters from
list";

For the CLR memory, you can select it from "Performance object" list, but I
am not sure if it is a helpful counter since the thread objects are
unmanaged.

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 8 '07 #14
cj
Ok, I am tracking Virtual Bytes and Threads. I'm also tracking Private
bytes and working set--I read an article that suggested those. I'm
going to keep the graph updating ever 5 minutes and we'll see where the
trend leads today. I know the memory trend will be up. I doubt the
threads will go up. But anyway, we'll see where it goes and I'll let
you know.

Thanks
Charles Wang[MSFT] wrote:
Hi cj,
Please refer to the following steps to add the counters:
1. Run perfmon.exe from command prompt;
2. Delete the original counters by clicking DELETE key on keyboard;
2. Click Add to add counters;
3. Select Process in the Performance object list;
4. Select your process name in the list of "Select instances from list";
5. Add Thread Count and Virtual Bytes from the list "Select counters from
list";

For the CLR memory, you can select it from "Performance object" list, but I
am not sure if it is a helpful counter since the thread objects are
unmanaged.

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 8 '07 #15
cj
Hi Charles, I responded to you via email so I could send you a picture
of the graph. For what it is worth to others I'm posting this here as well.

I've been running perfmon all day and this is what I have now.
Threadcount has fluctuated normally. I see no upward trend at all.
Virtual Bytes seems to be stepping up every few hours. I don't knwo
what to make of private bytes and working set as they are going up at
about a 45 degree angle--(they seem to indicate a problem but I don't
know what). This program has been running for over a year now without
any problems but the pc is scheduled to reboot weekly. We never looked
at the memory until now. The scheduled reboot got turned off and it
went two weeks and someone noticed an error on the screen that said we
were running out of virtual memory. That's what got us started looking
into this. The graph is set to update every 5 minutes.

Thanks for your help

Charles Wang[MSFT] wrote:
Hi cj,
Please refer to the following steps to add the counters:
1. Run perfmon.exe from command prompt;
2. Delete the original counters by clicking DELETE key on keyboard;
2. Click Add to add counters;
3. Select Process in the Performance object list;
4. Select your process name in the list of "Select instances from list";
5. Add Thread Count and Virtual Bytes from the list "Select counters from
list";

For the CLR memory, you can select it from "Performance object" list, but I
am not sure if it is a helpful counter since the thread objects are
unmanaged.

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 8 '07 #16
cj
And I see the email I sent you came back undeliverable. Well there's
1001 ways to do things so I'll find another but I gotta get home to do that.

cj wrote:
Hi Charles, I responded to you via email so I could send you a picture
of the graph. For what it is worth to others I'm posting this here as
well.

I've been running perfmon all day and this is what I have now.
Threadcount has fluctuated normally. I see no upward trend at all.
Virtual Bytes seems to be stepping up every few hours. I don't knwo
what to make of private bytes and working set as they are going up at
about a 45 degree angle--(they seem to indicate a problem but I don't
know what). This program has been running for over a year now without
any problems but the pc is scheduled to reboot weekly. We never looked
at the memory until now. The scheduled reboot got turned off and it
went two weeks and someone noticed an error on the screen that said we
were running out of virtual memory. That's what got us started looking
into this. The graph is set to update every 5 minutes.

Thanks for your help

Charles Wang[MSFT] wrote:
>Hi cj,
Please refer to the following steps to add the counters:
1. Run perfmon.exe from command prompt;
2. Delete the original counters by clicking DELETE key on keyboard;
2. Click Add to add counters;
3. Select Process in the Performance object list;
4. Select your process name in the list of "Select instances from list";
5. Add Thread Count and Virtual Bytes from the list "Select counters
from list";

For the CLR memory, you can select it from "Performance object" list,
but I am not sure if it is a helpful counter since the thread objects
are unmanaged.
Hope this helps. If you have any other questions or concerns, please
feel free to let me know.
Best regards,
Charles Wang
Microsoft Online Community Support
================================================= ====
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif

ications

If you are using Outlook Express, please make sure you clear the check
box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

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.
================================================= ===== When responding
to posts, please "Reply to Group" via your newsreader so that others
may learn and benefit from this issue.
================================================= =====
This posting is provided "AS IS" with no warranties, and confers no
rights. ================================================== ====

Jun 8 '07 #17
cj
Here's the picture:

http://img167.imageshack.us/my.php?i...enshot2mq9.jpg

cj wrote:
And I see the email I sent you came back undeliverable. Well there's
1001 ways to do things so I'll find another but I gotta get home to do
that.

cj wrote:
>Hi Charles, I responded to you via email so I could send you a
picture of the graph. For what it is worth to others I'm posting this
here as well.

I've been running perfmon all day and this is what I have now.
Threadcount has fluctuated normally. I see no upward trend at all.
Virtual Bytes seems to be stepping up every few hours. I don't knwo
what to make of private bytes and working set as they are going up at
about a 45 degree angle--(they seem to indicate a problem but I don't
know what). This program has been running for over a year now without
any problems but the pc is scheduled to reboot weekly. We never
looked at the memory until now. The scheduled reboot got turned off
and it went two weeks and someone noticed an error on the screen that
said we were running out of virtual memory. That's what got us
started looking into this. The graph is set to update every 5 minutes.

Thanks for your help

Charles Wang[MSFT] wrote:
>>Hi cj,
Please refer to the following steps to add the counters:
1. Run perfmon.exe from command prompt;
2. Delete the original counters by clicking DELETE key on keyboard;
2. Click Add to add counters;
3. Select Process in the Performance object list;
4. Select your process name in the list of "Select instances from list";
5. Add Thread Count and Virtual Bytes from the list "Select counters
from list";

For the CLR memory, you can select it from "Performance object" list,
but I am not sure if it is a helpful counter since the thread objects
are unmanaged.
Hope this helps. If you have any other questions or concerns, please
feel free to let me know.
Best regards,
Charles Wang
Microsoft Online Community Support
================================================ =====
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif

ications

If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply promptly.

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.
================================================ ====== When
responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
================================================ ======
This posting is provided "AS IS" with no warranties, and confers no
rights. ================================================== ====

Jun 9 '07 #18
Hi cj,
The continuous increase in the Process\Private Bytes counter indicates a
possible memory leak. I recommend that you carefully check your code to see
if some unmanaged objects/resources were not released after they are used.

Also, you may refer to the section Step 2: Identify Workload of this
article:
Performance Testing for Application Blocks
http://msdn2.microsoft.com/en-us/library/ms998241.aspx

NOTE: This issue is memory related. To track the root cause, memory dump
analysis may be required, however this work can only be done by CSS. Our
managed newsgroup is focused on break/fix issues that are neither urgent
nor complex. If the issue is urgent to your business, it is recommended
that you contact Microsoft Customer Support Services (CSS) via telephone so
that a dedicated Support Professional can assist you in a more efficient
manner. Please be advised that contacting phone support will be a charged
call.

To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default...S;PHONENUMBERS

If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 11 '07 #19
cj
Forgive me for asking a dumb question but what would be unmanaged
objects/resources? I thought all .net programs were managed.
Charles Wang[MSFT] wrote:
Hi cj,
The continuous increase in the Process\Private Bytes counter indicates a
possible memory leak. I recommend that you carefully check your code to see
if some unmanaged objects/resources were not released after they are used.

Also, you may refer to the section Step 2: Identify Workload of this
article:
Performance Testing for Application Blocks
http://msdn2.microsoft.com/en-us/library/ms998241.aspx

NOTE: This issue is memory related. To track the root cause, memory dump
analysis may be required, however this work can only be done by CSS. Our
managed newsgroup is focused on break/fix issues that are neither urgent
nor complex. If the issue is urgent to your business, it is recommended
that you contact Microsoft Customer Support Services (CSS) via telephone so
that a dedicated Support Professional can assist you in a more efficient
manner. Please be advised that contacting phone support will be a charged
call.

To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default...S;PHONENUMBERS

If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 11 '07 #20
Forgive me for asking a dumb question but what would be unmanaged
objects/resources? I thought all .net programs were managed.
In .Net, Memory is managed, but filehandles, COM Objects and other things
are not.

--
Rory
Jun 11 '07 #21
cj
But memory is the issue here (memory leak). Are you saying some memory
is managed and some is not?

Rory Becker wrote:
>Forgive me for asking a dumb question but what would be unmanaged
objects/resources? I thought all .net programs were managed.

In .Net, Memory is managed, but filehandles, COM Objects and other
things are not.

--
Rory

Jun 11 '07 #22
cj
Maybe this is a better use of our time--to make sure I'm ending objects
correctly.

Do you see anything wrong with this class? It called by all my threads
whenever they need to log a transaction.

Public Class MyStringLogger
Private Shared m_loglock As New Object

Public Shared Sub Write(ByVal fileName As String, ByVal strToWrite
As String)
SyncLock (m_loglock)
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
Catch
'if it fails forget it--not really that important
anyway
End Try
End SyncLock
End Sub
End Class

Do I need sw.dispose() after sw.close()?

I've always wondered how to ensure it's closed in case an error occurs
in opening the file or writing to it etc. In the case above if it fails
to write the file it would be left open I suppose--then again since it
is declared inside the try catch block it should cease to exist when
that section of code is done executing. Right? The network might be
down and the file can't be written to so I have to plan for this stuff.
Charles Wang[MSFT] wrote:
Hi cj,
The continuous increase in the Process\Private Bytes counter indicates a
possible memory leak. I recommend that you carefully check your code to see
if some unmanaged objects/resources were not released after they are used.

Also, you may refer to the section Step 2: Identify Workload of this
article:
Performance Testing for Application Blocks
http://msdn2.microsoft.com/en-us/library/ms998241.aspx

NOTE: This issue is memory related. To track the root cause, memory dump
analysis may be required, however this work can only be done by CSS. Our
managed newsgroup is focused on break/fix issues that are neither urgent
nor complex. If the issue is urgent to your business, it is recommended
that you contact Microsoft Customer Support Services (CSS) via telephone so
that a dedicated Support Professional can assist you in a more efficient
manner. Please be advised that contacting phone support will be a charged
call.

To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default...S;PHONENUMBERS

If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 11 '07 #23
Hi cj,
Generally for COM, unmanaged DLL, pointers, and file handles etc, they are
unmanaged. For .NET CLR objects, they are managed.

For managed and unmanaged code interoperability, you can refer to:
An Overview of Managed/Unmanaged Code Interoperability
http://msdn2.microsoft.com/en-us/library/ms973872.aspx

Unmanaged code may cause memory leak however even managed code may also
probably cause the issue which appears to have a memory leak. I recommend
that you refer to this article:
How to identify memory leaks in the common language runtime
http://support.microsoft.com/kb/318263

You may refer to the KB article and check if there is similar issue in your
code.
Please feel free to let me know if you have any other questions or
concerns. I am glad to work with you for further research.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====



Jun 12 '07 #24
cj
Charles, I've been reading and I don't get the managed vs unmanaged
because first I read that all .net code is managed then I keep seeing
where everything I use is unmanaged. File operations and even sql
connections. Anyway I just read an article that said if the object has
a .dispose method use it. That makes sense to me. Given that advise
I'm going to look over my code and see what I can do. I'm going to
consider this thread finished as I think my questions on .dispose can
stand by themselves outside of this memory leak issue. Thanks for all
your help.

Charles Wang[MSFT] wrote:
Hi cj,
Generally for COM, unmanaged DLL, pointers, and file handles etc, they are
unmanaged. For .NET CLR objects, they are managed.

For managed and unmanaged code interoperability, you can refer to:
An Overview of Managed/Unmanaged Code Interoperability
http://msdn2.microsoft.com/en-us/library/ms973872.aspx

Unmanaged code may cause memory leak however even managed code may also
probably cause the issue which appears to have a memory leak. I recommend
that you refer to this article:
How to identify memory leaks in the common language runtime
http://support.microsoft.com/kb/318263

You may refer to the KB article and check if there is similar issue in your
code.
Please feel free to let me know if you have any other questions or
concerns. I am glad to work with you for further research.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 12 '07 #25
On Jun 11, 12:57 pm, cj <c...@nospam.nospamwrote:
Maybe this is a better use of our time--to make sure I'm ending objects
correctly.

Do you see anything wrong with this class? It called by all my threads
whenever they need to log a transaction.

Public Class MyStringLogger
Private Shared m_loglock As New Object

Public Shared Sub Write(ByVal fileName As String, ByVal strToWrite
As String)
SyncLock (m_loglock)
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
Catch
'if it fails forget it--not really that important
anyway
End Try
End SyncLock
End Sub
End Class

Do I need sw.dispose() after sw.close()?
No. sw.Close calls dispose internally. In fact, the implementation
is:

Public Sub Close ()
Me.Dispose(True)
GC.SupressFinalize(Me)
End Sub

CJ, you might want to look at VB.NET's USING statement. It makes a
lot of this stuff much easier, since it guarentees that Dispose will
be called - even if you exit via an exception. I would probably
implement your above block somehting like:

SyncLock (m_loglock)
Try
Using sw As New StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
End Using ' automatically closed
Catch
End Try
End SyncLock

Anyway, HTH

--
Tom Shelton

Jun 12 '07 #26
cj
I'll check into it.

Tom Shelton wrote:
On Jun 11, 12:57 pm, cj <c...@nospam.nospamwrote:
>Maybe this is a better use of our time--to make sure I'm ending objects
correctly.

Do you see anything wrong with this class? It called by all my threads
whenever they need to log a transaction.

Public Class MyStringLogger
Private Shared m_loglock As New Object

Public Shared Sub Write(ByVal fileName As String, ByVal strToWrite
As String)
SyncLock (m_loglock)
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
Catch
'if it fails forget it--not really that important
anyway
End Try
End SyncLock
End Sub
End Class

Do I need sw.dispose() after sw.close()?

No. sw.Close calls dispose internally. In fact, the implementation
is:

Public Sub Close ()
Me.Dispose(True)
GC.SupressFinalize(Me)
End Sub

CJ, you might want to look at VB.NET's USING statement. It makes a
lot of this stuff much easier, since it guarentees that Dispose will
be called - even if you exit via an exception. I would probably
implement your above block somehting like:

SyncLock (m_loglock)
Try
Using sw As New StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
End Using ' automatically closed
Catch
End Try
End SyncLock

Anyway, HTH

--
Tom Shelton
Jun 12 '07 #27
Hi cj,
Yes, it is wisdom to use Dispose method to release resources.

Not sure if you noticed the description in the KB article 318263:
=============================================
Additionally, a project may only appear to have a memory leak. This
condition can occur if many large objects (such as DataTable objects) are
declared and then added to a collection (such as a DataSet). The resources
that these objects own may never be released, and the resources are left
alive for the whole run of the program. This appears to be a leak, but
actually it is just a symptom of the way that memory is being allocated in
the program.
=============================================

All objects that implement IDispose interface have a Dispose method.
Dataset implement IDispose interface, so you can call explicitly call it to
release resources. Otherwise, you will wait for GC releasing the objects.,
however we do not know when GC collect the memory. For those temorporay
objects, such as returned large objects, please explicityly call Dispose
method to release resources after you use them.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 13 '07 #28
cj
I did notice that but I really think this is some form of leak. I've
got some more testing I'm running tonight. If this doesn't work I'll
have to figure out the using statement I guess.

Charles Wang[MSFT] wrote:
Hi cj,
Yes, it is wisdom to use Dispose method to release resources.

Not sure if you noticed the description in the KB article 318263:
=============================================
Additionally, a project may only appear to have a memory leak. This
condition can occur if many large objects (such as DataTable objects) are
declared and then added to a collection (such as a DataSet). The resources
that these objects own may never be released, and the resources are left
alive for the whole run of the program. This appears to be a leak, but
actually it is just a symptom of the way that memory is being allocated in
the program.
=============================================

All objects that implement IDispose interface have a Dispose method.
Dataset implement IDispose interface, so you can call explicitly call it to
release resources. Otherwise, you will wait for GC releasing the objects.,
however we do not know when GC collect the memory. For those temorporay
objects, such as returned large objects, please explicityly call Dispose
method to release resources after you use them.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 13 '07 #29
Hi cj,
Thanks for your updating and response.

Just feel free to post back if you encounter any problems in future. Have a
good day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 14 '07 #30
Hi cj,
How about this issue?
If you need any assistance, please feel free to post back.

Have a good day!

Charles Wang
Microsoft Online Community Support

================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 18 '07 #31
cj
Hi Charles,

I can't say that I've seen any improvement. Private Bytes and Working
Set climb steadily during the day when the system is busy. Virtual
Bytes slowly climbs. It'll remain flat for hours then jump up. Threads
have shown no signs of increase. I'm using dispose for everything that
offers it now. I haven't had time to look into Using yet.

Thanks for checking,
cj

Charles Wang[MSFT] wrote:
Hi cj,
How about this issue?
If you need any assistance, please feel free to post back.

Have a good day!

Charles Wang
Microsoft Online Community Support

================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====
Jun 19 '07 #32
Hi cj,
In this case, I recommend that you also add the following counters to
monitor your .NET application to see if the CLR memory is being used highly:
..NET CLR Memory\# Bytes in All Heaps
..NET CLR Memory\Large Object Heap Size
..NET CLR Memory\% Time in GC

Please feel free to post back once you collect the data. I am glad to work
with you for further assistance.
Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====



Jun 20 '07 #33
cj
Hi Charles,

I added the counters yesterday and it's been almost 24 hours now.
# Bytes in All Heaps fluctuates but has shown no signs of increase
Last 585284, Avg 565394, Min 399088, Max 860336
Large Object Heap Size hasn't changed since it started
Last 33816, Avg 33816, Min 33816, Max 33816
% Time in GC has fluctuated but is very small
Last .002, Avg .004, Min .001, Max .016

Private bytes continues to climb whever the system is active
Last 117538816, Avg 88500153, Min 25710592, Max 120004608
Working Set also continues to climb at the same rate as private bytes
Last 119078912, Avg 89172462, Min 25686016, Max 119353344
Virtual Bytest continues to climb in a stair step fashion--jumps up
every few hours.
Last 294690816, Avg 254321252, Min 161128448, Max 300130304
Thread Count shows no signs of increase
Last 16, Avg 15, Min 13, Max 18

I still need to look at Using. I've been busy on other things. This
doesn't cause a problem unless it goes over a week and normally it's
rebooted weekly. But I'm very curious as to what is going on and I
really appreciate you help.
Charles Wang[MSFT] wrote:
Hi cj,
In this case, I recommend that you also add the following counters to
monitor your .NET application to see if the CLR memory is being used highly:
.NET CLR Memory\# Bytes in All Heaps
.NET CLR Memory\Large Object Heap Size
.NET CLR Memory\% Time in GC

Please feel free to post back once you collect the data. I am glad to work
with you for further assistance.
Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 21 '07 #34
Hi cj,
Did you have some P/Invoke or COM interop in your code? Also, please checK
if there are some unmanaged resources such as bitmap, connections,
Filestream etc which may not be disposed after they are used.
I recommend that you refer to this article before you make further checking
to your code:
Garbage Collection: Automatic Memory Management in the Microsoft .NET
Framework
http://msdn.microsoft.com/msdnmag/issues/1100/gci/

Please feel free to let me know if you have any other questions or
concerns.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====


Jun 22 '07 #35
cj
I do have a COM control that does the TCP/IP communication. I also
write to files and access a SQL db in this program. As a result of
seeing the Memory usage climb I've started calling .dispose for all
objects I use that implement it. For example the class that writes to
the files--the only class in this prg that writes to files.

Public Class MyStringLogger
Private Shared m_loglock As New Object

Public Shared Sub Write(ByVal fileName As String, ByVal
strToWrite As String)
SyncLock (m_loglock)
'remark out this try catch block to prevent all writing
to disk
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
sw.Dispose()
Catch
End Try
End SyncLock
End Sub
End Class

My SQL connections are closed and disposed as soon as they are no longer
needed.

I've contacted Catalyst the COM provider and they advised me to use an
uninitialize method which I now use. They do not provide a dispose method.

Charles Wang[MSFT] wrote:
Hi cj,
Did you have some P/Invoke or COM interop in your code? Also, please checK
if there are some unmanaged resources such as bitmap, connections,
Filestream etc which may not be disposed after they are used.
I recommend that you refer to this article before you make further checking
to your code:
Garbage Collection: Automatic Memory Management in the Microsoft .NET
Framework
http://msdn.microsoft.com/msdnmag/issues/1100/gci/

Please feel free to let me know if you have any other questions or
concerns.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 22 '07 #36
Hi cj,
Sorry for delaying this response due to a sick leave.

If your SQL connections are closed and disposed as soon as they are no
longer needed, they won't be leaked. For the COM objects or references, you
may check if they provide a method to release themselves. Dispose method is
just a .NET class who implemented IDispose interface, however for those
unmanaged objects, if they were not wrapped in a .NET class which
implemented IDispose interface, you need to use their self-provided release
function to release themselves.

From the perfmon monitor result, we can see that this is a unmanged
resources leakage issue. The managed resources were controlled very well in
your application. I do not know what the COM component you used was, but
there might be another possible reason, if the COM component itself has
memory leaks, it is hard for you to correct it in your .NET application.

I recommend that you work with your COM developers to identify which COM
objects and references need to be released in what way.

Hope this helps. If you have any other questions or concerns, please feel
free to post back. I am glad to work with you for further assistance.

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 26 '07 #37
Hi cj,
What is going on with this issue? Please feel free to post back if you
encounter any issues.
Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 28 '07 #38
cj
Sorry Charles, other priorities came up and I haven't been able to work
on this for awhile now. I did add using around the SQL and file handles
but I encountered an unhanded exception somewhere after 8-10 hours of
running. I don't know what the cause was but since the memory was still
climbing anyway I changed the code back to before I added using.

I'd already spoken with the com vendor and he told me to make sure I
called .Uninitialize. I am but that doesn't help.

I don't like knowing it's using increasing amounts of memory and I can't
explain it but it runs incredibly well as long as the program is
restarted at least once a week. Thankfully that isn't a problem as when
we first wrote the program we had worried about the ability of the pc to
run a multi threaded app for weeks at a time w/o a reboot and the
program was written to reboot the pc on selected days at 2:00am. This
"memory leak" might have been occurring all along but nobody noticed
until the automatic reboot was turned off and it went just over 2 weeks
an gave the memory error.

I appreciate your help but I don't know what more we can do. As I have
time I'll keep trying things.

Charles Wang[MSFT] wrote:
Hi cj,
What is going on with this issue? Please feel free to post back if you
encounter any issues.
Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====
Jun 28 '07 #39
Hi cj,
I appreciate your updating and feedback.

Since this issue is complex and may need dump analysis for tracking the
root cause, I would like to recommend a senior support channel for you.
Effectively and immediately you can contact Microsoft Customer Support
Services (CSS) via telephone so that a dedicated Support Professional can
assist you in a more efficient manner. Please be advised that contacting
phone support will be a charged call.

To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default...S;PHONENUMBERS

If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.

If you have any other questions or concerns, please feel free to let me
know.
Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
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.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Jun 29 '07 #40

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

Similar topics

6
by: Dan Kelley | last post by:
We have a multithreaded app that responds to events, and writes these events to a text file. This text file is used by an external system for further processing. We want to be able to write...
7
by: Sidd | last post by:
Hi, I tried finding and example of multithreaded client-serve program in python. Can any one please tell me how to write a multithreaded client-server programn in python such that 1.It can handle...
14
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after...
14
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the...
7
by: Pavils Jurjans | last post by:
Hello, I wanted to get some light in the subject. As I develop ASP.NET applications, it's necessary to understand how exactly the server- communication happens. It seems like initially...
8
by: Fred | last post by:
Hello, Our website is currently developed in ASP/Mysql 4. The dedicated servers on which it is currently hosted arrive at saturation. Here is their configuration: - 1 server PIV 2,8Ghz 1GB...
0
by: greg | last post by:
Hi, I am hosting hundreds of websites on a webserver using a combination of sql and asp. SQL is on a different server. The web server is running win 2003 iis 6 with a single processor and 1 GB...
3
by: groups | last post by:
Hi all, I've recently ported a rather large C application to run multithreaded. A few functions have seriously deteriorated in performance, in particular when accessing a rather large global...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
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...
1
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...
0
tracyyun
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...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 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.