Is there an issue with Suspended threads leaking? 
Author Message
 Is there an issue with Suspended threads leaking?

We have an application that uses threads to do some work
and when the work is completed we suspend the thread.  We
do this because a thread loads a VB6 dll and this takes up
to 20 seconds to load, we want to load it once on a thread
and reuse the thread many times.

This works very well except for a memory leak when one or
many thread(s) is/are suspended and one thread is
processing, then we have a huge memory leak.  We do not
have a leak if there has only been one thread spawned and
it is processing or suspended.  We do not have a leak if n
threads are spawned and all n threads are processing.  We
only have a leak when a thread is suspended and one or
many threads are processing.  We can recover all the
memory by destroying the threads but this causes us to
reload the VB6 dll which takes up to 20 seconds.

We have added a System.Gc.Collect() at the end of a thread
process before it is suspended.  This does clean up memory
but it does not stop the leak.

When a thread is destroyed we are using Marshal.ReleaseCom
on the VB6 Dll's, this does clean up the memory used by
the object and thread.

Is there an issue with Suspended threads leaking?

Thanks in advance.

Marty



Mon, 26 Sep 2005 00:15:32 GMT  
 Is there an issue with Suspended threads leaking?
Hi, Marty

I can't find any reference to a problem of this type.

Are you using vs.net 2002 or 2003 final beta?  Is your application WinForm
or WebForm based?

Is the delay in loading your VB6 DLL exclusively load time, or does that
also include initializing the classes?

How big is "huge"?  Do you have a feeling for what is leaking the memory:  
Is it the DLLs or your program?

Could you create a >small< sample that duplicates the problem so that we
can investigate here?

Thanks,

John Eikanger
Microsoft Visual Basic Team

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation.  All rights reserved.
--------------------
| Content-Class: urn:content-classes:message


| Subject: Is there an issue with Suspended threads leaking?
| Date: Wed, 9 Apr 2003 09:15:32 -0700
| Lines: 31
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| We have an application that uses threads to do some work
| and when the work is completed we suspend the thread.  We
| do this because a thread loads a VB6 dll and this takes up
| to 20 seconds to load, we want to load it once on a thread
| and reuse the thread many times.
|
| This works very well except for a memory leak when one or
| many thread(s) is/are suspended and one thread is
| processing, then we have a huge memory leak.  We do not
| have a leak if there has only been one thread spawned and
| it is processing or suspended.  We do not have a leak if n
| threads are spawned and all n threads are processing.  We
| only have a leak when a thread is suspended and one or
| many threads are processing.  We can recover all the
| memory by destroying the threads but this causes us to
| reload the VB6 dll which takes up to 20 seconds.
|
| We have added a System.Gc.Collect() at the end of a thread
| process before it is suspended.  This does clean up memory
| but it does not stop the leak.
|
| When a thread is destroyed we are using Marshal.ReleaseCom
| on the VB6 Dll's, this does clean up the memory used by
| the object and thread.
|
| Is there an issue with Suspended threads leaking?
|
| Thanks in advance.
|
| Marty
|
|



Mon, 26 Sep 2005 03:34:59 GMT  
 Is there an issue with Suspended threads leaking?
John,

Thanks for your quick response.  Here are answers to your questions and I
will work on a small app that recreates the problem.

1.  We are using vs.net 2002.
2.  Our app is a windows service.
3.  Loading the vb6 dll is all load time.
4.  It is leaking about 1meg per calculation and a calculation takes about
10 seconds with a fully loaded vb6 dll, otherwise it takes about 30 seconds.
So, when we are run 1000's of these calcs and we have a suspended thread the
leak is huge.
5.  I do not have a feeling for what is leaking, since the leak occurs only
when the thread is suspended.
6.  I will work on a small test app and try to reproduce the error.

Thanks again.

Marty



Quote:
> Hi, Marty

> I can't find any reference to a problem of this type.

> Are you using vs.net 2002 or 2003 final beta?  Is your application WinForm
> or WebForm based?

> Is the delay in loading your VB6 DLL exclusively load time, or does that
> also include initializing the classes?

> How big is "huge"?  Do you have a feeling for what is leaking the memory:
> Is it the DLLs or your program?

> Could you create a >small< sample that duplicates the problem so that we
> can investigate here?

> Thanks,

> John Eikanger
> Microsoft Visual Basic Team

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> (c) 2003 Microsoft Corporation.  All rights reserved.
> --------------------
> | Content-Class: urn:content-classes:message


> | Subject: Is there an issue with Suspended threads leaking?
> | Date: Wed, 9 Apr 2003 09:15:32 -0700
> | Lines: 31
> | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
> |
> | We have an application that uses threads to do some work
> | and when the work is completed we suspend the thread.  We
> | do this because a thread loads a VB6 dll and this takes up
> | to 20 seconds to load, we want to load it once on a thread
> | and reuse the thread many times.
> |
> | This works very well except for a memory leak when one or
> | many thread(s) is/are suspended and one thread is
> | processing, then we have a huge memory leak.  We do not
> | have a leak if there has only been one thread spawned and
> | it is processing or suspended.  We do not have a leak if n
> | threads are spawned and all n threads are processing.  We
> | only have a leak when a thread is suspended and one or
> | many threads are processing.  We can recover all the
> | memory by destroying the threads but this causes us to
> | reload the VB6 dll which takes up to 20 seconds.
> |
> | We have added a System.Gc.Collect() at the end of a thread
> | process before it is suspended.  This does clean up memory
> | but it does not stop the leak.
> |
> | When a thread is destroyed we are using Marshal.ReleaseCom
> | on the VB6 Dll's, this does clean up the memory used by
> | the object and thread.
> |
> | Is there an issue with Suspended threads leaking?
> |
> | Thanks in advance.
> |
> | Marty
> |
> |



Mon, 26 Sep 2005 04:19:13 GMT  
 Is there an issue with Suspended threads leaking?
Hi, Marty

Strange stuff.  I'll talk to my debug guru and see if he has any
suggestions.

John Eikanger
Microsoft Visual Basic Team

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation.  All rights reserved.
--------------------



| Subject: Re: Is there an issue with Suspended threads leaking?
| Date: Wed, 9 Apr 2003 16:19:13 -0400
| Lines: 93
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| John,
|
| Thanks for your quick response.  Here are answers to your questions and I
| will work on a small app that recreates the problem.
|
| 1.  We are using vs.net 2002.
| 2.  Our app is a windows service.
| 3.  Loading the vb6 dll is all load time.
| 4.  It is leaking about 1meg per calculation and a calculation takes about
| 10 seconds with a fully loaded vb6 dll, otherwise it takes about 30
seconds.
| So, when we are run 1000's of these calcs and we have a suspended thread
the
| leak is huge.
| 5.  I do not have a feeling for what is leaking, since the leak occurs
only
| when the thread is suspended.
| 6.  I will work on a small test app and try to reproduce the error.
|
| Thanks again.
|
| Marty
|
|
|
|


| > Hi, Marty
| >
| > I can't find any reference to a problem of this type.
| >
| > Are you using vs.net 2002 or 2003 final beta?  Is your application
WinForm
| > or WebForm based?
| >
| > Is the delay in loading your VB6 DLL exclusively load time, or does that
| > also include initializing the classes?
| >
| > How big is "huge"?  Do you have a feeling for what is leaking the
memory:
| > Is it the DLLs or your program?
| >
| > Could you create a >small< sample that duplicates the problem so that we
| > can investigate here?
| >
| > Thanks,
| >
| > John Eikanger
| > Microsoft Visual Basic Team
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > (c) 2003 Microsoft Corporation.  All rights reserved.
| > --------------------
| > | Content-Class: urn:content-classes:message


| > | Subject: Is there an issue with Suspended threads leaking?
| > | Date: Wed, 9 Apr 2003 09:15:32 -0700
| > | Lines: 31
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > |
| > | We have an application that uses threads to do some work
| > | and when the work is completed we suspend the thread.  We
| > | do this because a thread loads a VB6 dll and this takes up
| > | to 20 seconds to load, we want to load it once on a thread
| > | and reuse the thread many times.
| > |
| > | This works very well except for a memory leak when one or
| > | many thread(s) is/are suspended and one thread is
| > | processing, then we have a huge memory leak.  We do not
| > | have a leak if there has only been one thread spawned and
| > | it is processing or suspended.  We do not have a leak if n
| > | threads are spawned and all n threads are processing.  We
| > | only have a leak when a thread is suspended and one or
| > | many threads are processing.  We can recover all the
| > | memory by destroying the threads but this causes us to
| > | reload the VB6 dll which takes up to 20 seconds.
| > |
| > | We have added a System.Gc.Collect() at the end of a thread
| > | process before it is suspended.  This does clean up memory
| > | but it does not stop the leak.
| > |
| > | When a thread is destroyed we are using Marshal.ReleaseCom
| > | on the VB6 Dll's, this does clean up the memory used by
| > | the object and thread.
| > |
| > | Is there an issue with Suspended threads leaking?
| > |
| > | Thanks in advance.
| > |
| > | Marty
| > |
| > |
| >
|
|
|



Mon, 26 Sep 2005 07:17:58 GMT  
 Is there an issue with Suspended threads leaking?
Update

I talked go my debug guru and he asked for clarification of this statement:

"We have added a System.Gc.Collect() at the end of a thread
process before it is suspended.  This does clean up memory
but it does not stop the leak."

What is the effect that you are seeing?  Does performing the GC reduce
memory?  Does the amount of memory climb after each GC?

Also, what tool are you using to measure the leak?  If you are not using
perfmon, you need to do so.

HTH,

John Eikanger
Microsoft Visual Basic Team

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation.  All rights reserved.



Mon, 26 Sep 2005 07:37:21 GMT  
 Is there an issue with Suspended threads leaking?
John,

We added the gc.collect in desperation, before a thread suspends we now call
this and it does seem to reduce the memory footprint of the service.  I will
run some more testing without the gc.collect, I do not believe we need to
call this before we suspend and I am sure we should not have to call
gc.collect.

Also, yes I have been using perfmon and also added the "working set"
performance counter for the service to the thread.  I append the beginning
and ending rawvalue to the text file.

Here is a sample of the output I collect, you can see that the BN thread is
suspended and after we start to leak.  (requestid and contactid are keys in
our system).

threadName    time    requestid    contactid    start kb    end kb    delta
En_45_56 2:38:12 AM 1020258 38171 490250240 492380160 2129920
BN_22_3  2:38:15 AM 849385 46668 491962368 491593728 -368640
En_45_56 2:38:15 AM 1020259 38179 492830720 490938368 -1892352
En_45_56 2:38:18 AM 1020260 38182 490975232 490242048 -733184
En_45_56 2:38:21 AM 1020261 38183 490254336 492277760 2023424
En_45_56 2:38:24 AM 1020262 38186 492277760 492564480 286720
En_45_56 2:38:28 AM 1020263 38191 492564480 494862336 2297856
En_45_56 2:38:31 AM 1020264 38195 494862336 493539328 -1323008
En_45_56 2:38:34 AM 1020265 38196 493539328 496201728 2662400
En_45_56 2:38:37 AM 1020266 38197 496205824 495149056 -1056768
En_45_56 2:38:40 AM 1020267 38199 495149056 497324032 2174976
En_45_56 2:38:43 AM 1020268 38201 497324032 495558656 -1765376
En_45_56 2:38:46 AM 1020269 38202 495558656 498950144 3391488
En_45_56 2:38:49 AM 1020270 38204 499064832 496517120 -2547712
En_45_56 2:38:52 AM 1020271 38209 496517120 499564544 3047424
En_45_56 2:38:56 AM 1020272 38211 499564544 501755904 2191360

I believe my numbers are correct.

Marty



Quote:
> Update

> I talked go my debug guru and he asked for clarification of this
statement:

> "We have added a System.Gc.Collect() at the end of a thread
> process before it is suspended.  This does clean up memory
> but it does not stop the leak."

> What is the effect that you are seeing?  Does performing the GC reduce
> memory?  Does the amount of memory climb after each GC?

> Also, what tool are you using to measure the leak?  If you are not using
> perfmon, you need to do so.

> HTH,

> John Eikanger
> Microsoft Visual Basic Team

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> (c) 2003 Microsoft Corporation.  All rights reserved.



Mon, 26 Sep 2005 08:46:21 GMT  
 Is there an issue with Suspended threads leaking?
Hi, Marty

Thanks for the data.

As I reviewed your posts I was not able to confirn what language your
dotnet app is written in.

We are planning to send you a tool to help you debug the leak on your end,
hopefully without putting you to a lot of effort creating a repro case.  I
should know more on Monday.

HTH,

John Eikanger
Microsoft Visual Basic Team

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation.  All rights reserved.
--------------------






| Subject: Re: Is there an issue with Suspended threads leaking?
| Date: Wed, 9 Apr 2003 20:46:21 -0400
| Lines: 66
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 168.168.67.112
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:101118
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| John,
|
| We added the gc.collect in desperation, before a thread suspends we now
call
| this and it does seem to reduce the memory footprint of the service.  I
will
| run some more testing without the gc.collect, I do not believe we need to
| call this before we suspend and I am sure we should not have to call
| gc.collect.
|
| Also, yes I have been using perfmon and also added the "working set"
| performance counter for the service to the thread.  I append the beginning
| and ending rawvalue to the text file.
|
| Here is a sample of the output I collect, you can see that the BN thread
is
| suspended and after we start to leak.  (requestid and contactid are keys
in
| our system).
|
| threadName    time    requestid    contactid    start kb    end kb    
delta
| En_45_56 2:38:12 AM 1020258 38171 490250240 492380160 2129920
| BN_22_3  2:38:15 AM 849385 46668 491962368 491593728 -368640
| En_45_56 2:38:15 AM 1020259 38179 492830720 490938368 -1892352
| En_45_56 2:38:18 AM 1020260 38182 490975232 490242048 -733184
| En_45_56 2:38:21 AM 1020261 38183 490254336 492277760 2023424
| En_45_56 2:38:24 AM 1020262 38186 492277760 492564480 286720
| En_45_56 2:38:28 AM 1020263 38191 492564480 494862336 2297856
| En_45_56 2:38:31 AM 1020264 38195 494862336 493539328 -1323008
| En_45_56 2:38:34 AM 1020265 38196 493539328 496201728 2662400
| En_45_56 2:38:37 AM 1020266 38197 496205824 495149056 -1056768
| En_45_56 2:38:40 AM 1020267 38199 495149056 497324032 2174976
| En_45_56 2:38:43 AM 1020268 38201 497324032 495558656 -1765376
| En_45_56 2:38:46 AM 1020269 38202 495558656 498950144 3391488
| En_45_56 2:38:49 AM 1020270 38204 499064832 496517120 -2547712
| En_45_56 2:38:52 AM 1020271 38209 496517120 499564544 3047424
| En_45_56 2:38:56 AM 1020272 38211 499564544 501755904 2191360
|
| I believe my numbers are correct.
|
| Marty
|


| > Update
| >
| > I talked go my debug guru and he asked for clarification of this
| statement:
| >
| > "We have added a System.Gc.Collect() at the end of a thread
| > process before it is suspended.  This does clean up memory
| > but it does not stop the leak."
| >
| > What is the effect that you are seeing?  Does performing the GC reduce
| > memory?  Does the amount of memory climb after each GC?
| >
| > Also, what tool are you using to measure the leak?  If you are not using
| > perfmon, you need to do so.
| >
| > HTH,
| >
| > John Eikanger
| > Microsoft Visual Basic Team
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > (c) 2003 Microsoft Corporation.  All rights reserved.
| >
|
|
|



Wed, 28 Sep 2005 07:16:44 GMT  
 Is there an issue with Suspended threads leaking?
Hi, Marty

It looks like the best plan would be for us to take this offline and report
what we find out.  Would you please send me an email with your contact
information so that I can create a grace (no cost) support incident to
address the problem?  Just leave 'online.' out of my no spam email.

Among the things we will need is a pdb file for your VB6 DLL.  If you
haven't done that before, let me know and I will help you get that setup

HTH,

John Eikanger
Microsoft Visual Basic Team

This posting is provided AS IS with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation.  All rights reserved.



Fri, 30 Sep 2005 10:47:28 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Suspending threads

2. I can't abort suspended thread

3. Suspending a tread pending variable by another thread?

4. VB6 thread local storage leak?

5. VB6 thread local storage leak?

6. I am using the Compare MS Project COM Program and having issues

7. Threading issue..

8. Seeking advice on threading issues

9. Synchronization issue - Threading (volatile keyword)

10. VB Threading issue

11. DLL Threading Issue

12. Threading Issues with VB6

 

 
Powered by phpBB® Forum Software