PC Review


Reply
Thread Tools Rate Thread

AccessPoint accessPoint in currentAdapter.PreferredAccessPointsMemory Leak

 
 
.net CF'er
Guest
Posts: n/a
 
      10th Jul 2009
Hello All, I think I have narrowed a memory leak down to this code. I
am using OpenNETCF.Net Version 2.1.
As you can see, I am really doing nothing in the following code accept
getting the current adapters preferredAccessPoint collection. I plan
on digging into this code this weekend/next week but wanted to throw
it out on the forum in hopes others have a solution. The pattern
appears to be a 200K drop in available virtual every ~ 15 calls to the
function that runs the code below. A perfmon diff shows no
accumulations of objects in managed code. It will run until the exe
eats up all 32MB.

// Add other preferred access points
foreach (AccessPoint accessPoint in
currentAdapter.PreferredAccessPoints)
{
if (!results.ContainsKey
(accessPoint.Name))
{
try
{
results.Add
(accessPoint.Name,null);
}
catch { }
}
}

I did a quick search on this and only found the following from Chris
T. The difference is this guy was using NetCF ver 1.4 and the 2.1
version I am using does not have a reference to ndisAccess and the
class is only 229 lines. it does have a RefreshList function with no
need to close any Handles.
-----------

There is a leak in AccessPointCollection, near line 329 in RefreshList
().
You need to add the following:

FileEx.CloseHandle( ndisAccess );


before leaving that method.

I'm unable to find anything else actually leaking. All of the managed
arrays, I would think, should be getting freed when the garbage
collector
decides that it's time. There's very little, if any, unmanaged memory
allocated when that series of steps is performed, so there isn't a lot
of
room for things to get lost.
-------------




 
Reply With Quote
 
 
 
 
Chris Tacke, MVP
Guest
Posts: n/a
 
      12th Jul 2009
Have you tried anything newer? We're already at version 2.3, and we made a
lot of changes and did a lot of fixes around WiFi in the 2.3 release.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

".net CF'er" <(E-Mail Removed)> wrote in message
news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...
> Hello All, I think I have narrowed a memory leak down to this code. I
> am using OpenNETCF.Net Version 2.1.
> As you can see, I am really doing nothing in the following code accept
> getting the current adapters preferredAccessPoint collection. I plan
> on digging into this code this weekend/next week but wanted to throw
> it out on the forum in hopes others have a solution. The pattern
> appears to be a 200K drop in available virtual every ~ 15 calls to the
> function that runs the code below. A perfmon diff shows no
> accumulations of objects in managed code. It will run until the exe
> eats up all 32MB.
>
> // Add other preferred access points
> foreach (AccessPoint accessPoint in
> currentAdapter.PreferredAccessPoints)
> {
> if (!results.ContainsKey
> (accessPoint.Name))
> {
> try
> {
> results.Add
> (accessPoint.Name,null);
> }
> catch { }
> }
> }
>
> I did a quick search on this and only found the following from Chris
> T. The difference is this guy was using NetCF ver 1.4 and the 2.1
> version I am using does not have a reference to ndisAccess and the
> class is only 229 lines. it does have a RefreshList function with no
> need to close any Handles.
> -----------
>
> There is a leak in AccessPointCollection, near line 329 in RefreshList
> ().
> You need to add the following:
>
> FileEx.CloseHandle( ndisAccess );
>
>
> before leaving that method.
>
> I'm unable to find anything else actually leaking. All of the managed
> arrays, I would think, should be getting freed when the garbage
> collector
> decides that it's time. There's very little, if any, unmanaged memory
> allocated when that series of steps is performed, so there isn't a lot
> of
> room for things to get lost.
> -------------
>
>
>
>


 
Reply With Quote
 
.net CF'er
Guest
Posts: n/a
 
      15th Jul 2009
On Jul 11, 10:48*pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
wrote:
> Have you tried anything newer? *We're already at version 2.3, and we made a
> lot of changes and did a lot of fixes around WiFi in the 2.3 release.
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Giving back to the embedded communityhttp://community.OpenNETCF.com
>
> ".net CF'er" <jderu...@gmail.com> wrote in message
>
> news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...
>
>
>
> > Hello All, I think I have narrowed a memory leak down to this code. I
> > am using OpenNETCF.Net Version 2.1.
> > As you can see, I am really doing nothing in the following code accept
> > getting the current adapters preferredAccessPoint collection. I plan
> > on digging into this code this weekend/next week but wanted to throw
> > it out on the forum in hopes others have a solution. The pattern
> > appears to be a 200K drop in available virtual every ~ 15 calls to the
> > function that runs the code below. A perfmon diff shows no
> > accumulations of objects in managed code. It will run until the exe
> > eats up all 32MB.

>
> > * * * * * * * * * * * * * *// Add other preferred access points
> > * * * * * * * * * * * * * *foreach (AccessPoint accessPoint in
> > currentAdapter.PreferredAccessPoints)
> > * * * * * * * * * * * * * *{
> > * * * * * * * * * * * * * * * *if (!results.ContainsKey
> > (accessPoint.Name))
> > * * * * * * * * * * * * * * * *{
> > * * * * * * * * * * * * * * * * * *try
> > * * * * * * * * * * * * * * * * * *{
> > * * * * * * * * * * * * * * * * * ** *results.Add
> > (accessPoint.Name,null);
> > * * * * * * * * * * * * * * * * * *}
> > * * * * * * * * * * * * * * * * * *catch { }
> > * * * * * * * * * * * * * * * *}
> > * * * * * * * * * * * * * *}

>
> > I did a quick search on this and only found the following from Chris
> > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
> > version I am using does not have a reference to ndisAccess and the
> > class is only 229 lines. it does have a RefreshList function with no
> > need to close any Handles.
> > -----------

>
> > There is a leak in AccessPointCollection, near line 329 in RefreshList
> > ().
> > You need to add the following:

>
> > FileEx.CloseHandle( ndisAccess );

>
> > before leaving that method.

>
> > I'm unable to find anything else actually leaking. All of the managed
> > arrays, I would think, should be getting freed when the garbage
> > collector
> > decides that it's time. There's very little, if any, unmanaged memory
> > allocated when that series of steps is performed, so there isn't a lot
> > of
> > room for things to get lost.
> > -------------- Hide quoted text -

>
> - Show quoted text -


Prelim results is that it acts the same between 2.3 and 2.1, still
seems to be dropping in 200K buckets.

I will know more tomorrow.
 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      15th Jul 2009
Are you, by any chance, not disposing of something, an AccessPoint or an
Adapter, when you're done with it? That sounds like a case where a large
structure that one of those classes allocated to get SSID information might
not get thrown away unless you call Dispose(), Close() or something of that
nature, possibly because you are storing things in an array for later use or
something.

Paul T.

".net CF'er" <(E-Mail Removed)> wrote in message
news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)...
On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
wrote:
> Have you tried anything newer? We're already at version 2.3, and we made a
> lot of changes and did a lot of fixes around WiFi in the 2.3 release.
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Giving back to the embedded communityhttp://community.OpenNETCF.com
>
> ".net CF'er" <jderu...@gmail.com> wrote in message
>
> news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...
>
>
>
> > Hello All, I think I have narrowed a memory leak down to this code. I
> > am using OpenNETCF.Net Version 2.1.
> > As you can see, I am really doing nothing in the following code accept
> > getting the current adapters preferredAccessPoint collection. I plan
> > on digging into this code this weekend/next week but wanted to throw
> > it out on the forum in hopes others have a solution. The pattern
> > appears to be a 200K drop in available virtual every ~ 15 calls to the
> > function that runs the code below. A perfmon diff shows no
> > accumulations of objects in managed code. It will run until the exe
> > eats up all 32MB.

>
> > // Add other preferred access points
> > foreach (AccessPoint accessPoint in
> > currentAdapter.PreferredAccessPoints)
> > {
> > if (!results.ContainsKey
> > (accessPoint.Name))
> > {
> > try
> > {
> > results.Add
> > (accessPoint.Name,null);
> > }
> > catch { }
> > }
> > }

>
> > I did a quick search on this and only found the following from Chris
> > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
> > version I am using does not have a reference to ndisAccess and the
> > class is only 229 lines. it does have a RefreshList function with no
> > need to close any Handles.
> > -----------

>
> > There is a leak in AccessPointCollection, near line 329 in RefreshList
> > ().
> > You need to add the following:

>
> > FileEx.CloseHandle( ndisAccess );

>
> > before leaving that method.

>
> > I'm unable to find anything else actually leaking. All of the managed
> > arrays, I would think, should be getting freed when the garbage
> > collector
> > decides that it's time. There's very little, if any, unmanaged memory
> > allocated when that series of steps is performed, so there isn't a lot
> > of
> > room for things to get lost.
> > -------------- Hide quoted text -

>
> - Show quoted text -


Prelim results is that it acts the same between 2.3 and 2.1, still
seems to be dropping in 200K buckets.

I will know more tomorrow.


 
Reply With Quote
 
.net CF'er
Guest
Posts: n/a
 
      16th Jul 2009
On Jul 15, 4:13*pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
> Are you, by any chance, not disposing of something, an AccessPoint or an
> Adapter, when you're done with it? *That sounds like a case where a large
> structure that one of those classes allocated to get SSID information might
> not get thrown away unless you call Dispose(), Close() or something of that
> nature, possibly because you are storing things in an array for later useor
> something.
>
> Paul T.
>
> ".net CF'er" <jderu...@gmail.com> wrote in message
>
> news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)...
> On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
> wrote:
>
>
>
>
>
> > Have you tried anything newer? We're already at version 2.3, and we made a
> > lot of changes and did a lot of fixes around WiFi in the 2.3 release.

>
> > --

>
> > Chris Tacke, Embedded MVP
> > OpenNETCF Consulting
> > Giving back to the embedded communityhttp://community.OpenNETCF.com

>
> > ".net CF'er" <jderu...@gmail.com> wrote in message

>
> >news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)....

>
> > > Hello All, I think I have narrowed a memory leak down to this code. I
> > > am using OpenNETCF.Net Version 2.1.
> > > As you can see, I am really doing nothing in the following code accept
> > > getting the current adapters preferredAccessPoint collection. I plan
> > > on digging into this code this weekend/next week but wanted to throw
> > > it out on the forum in hopes others have a solution. The pattern
> > > appears to be a 200K drop in available virtual every ~ 15 calls to the
> > > function that runs the code below. A perfmon diff shows no
> > > accumulations of objects in managed code. It will run until the exe
> > > eats up all 32MB.

>
> > > // Add other preferred access points
> > > foreach (AccessPoint accessPoint in
> > > currentAdapter.PreferredAccessPoints)
> > > {
> > > if (!results.ContainsKey
> > > (accessPoint.Name))
> > > {
> > > try
> > > {
> > > results.Add
> > > (accessPoint.Name,null);
> > > }
> > > catch { }
> > > }
> > > }

>
> > > I did a quick search on this and only found the following from Chris
> > > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
> > > version I am using does not have a reference to ndisAccess and the
> > > class is only 229 lines. it does have a RefreshList function with no
> > > need to close any Handles.
> > > -----------

>
> > > There is a leak in AccessPointCollection, near line 329 in RefreshList
> > > ().
> > > You need to add the following:

>
> > > FileEx.CloseHandle( ndisAccess );

>
> > > before leaving that method.

>
> > > I'm unable to find anything else actually leaking. All of the managed
> > > arrays, I would think, should be getting freed when the garbage
> > > collector
> > > decides that it's time. There's very little, if any, unmanaged memory
> > > allocated when that series of steps is performed, so there isn't a lot
> > > of
> > > room for things to get lost.
> > > -------------- Hide quoted text -

>
> > - Show quoted text -

>
> Prelim results is that it acts the same between 2.3 and 2.1, still
> seems to be dropping in 200K buckets.
>
> I will know more tomorrow.- Hide quoted text -
>
> - Show quoted text -


Hello Paul,
I am using INetworkInterface, WirelessZeroConfigNetworkInterface, and
NetworkInformation.AccessPoint and do not see a close or dispose
function on any of them.?
 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Jul 2009
OK, it appears to me that there may a missing deallocation for the raw data
portion of the INTF_ENTRY struct in the AccessPointCollection methods for
the allocation near line 173. I think that Chris would have to identify and
apply a fix.

Paul T.

".net CF'er" <(E-Mail Removed)> wrote in message
news:90f24a41-b8b0-4ee9-8080-(E-Mail Removed)...
On Jul 15, 4:13 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
> Are you, by any chance, not disposing of something, an AccessPoint or an
> Adapter, when you're done with it? That sounds like a case where a large
> structure that one of those classes allocated to get SSID information
> might
> not get thrown away unless you call Dispose(), Close() or something of
> that
> nature, possibly because you are storing things in an array for later use
> or
> something.
>
> Paul T.
>
> ".net CF'er" <jderu...@gmail.com> wrote in message
>
> news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)...
> On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
> wrote:
>
>
>
>
>
> > Have you tried anything newer? We're already at version 2.3, and we made
> > a
> > lot of changes and did a lot of fixes around WiFi in the 2.3 release.

>
> > --

>
> > Chris Tacke, Embedded MVP
> > OpenNETCF Consulting
> > Giving back to the embedded communityhttp://community.OpenNETCF.com

>
> > ".net CF'er" <jderu...@gmail.com> wrote in message

>
> >news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...

>
> > > Hello All, I think I have narrowed a memory leak down to this code. I
> > > am using OpenNETCF.Net Version 2.1.
> > > As you can see, I am really doing nothing in the following code accept
> > > getting the current adapters preferredAccessPoint collection. I plan
> > > on digging into this code this weekend/next week but wanted to throw
> > > it out on the forum in hopes others have a solution. The pattern
> > > appears to be a 200K drop in available virtual every ~ 15 calls to the
> > > function that runs the code below. A perfmon diff shows no
> > > accumulations of objects in managed code. It will run until the exe
> > > eats up all 32MB.

>
> > > // Add other preferred access points
> > > foreach (AccessPoint accessPoint in
> > > currentAdapter.PreferredAccessPoints)
> > > {
> > > if (!results.ContainsKey
> > > (accessPoint.Name))
> > > {
> > > try
> > > {
> > > results.Add
> > > (accessPoint.Name,null);
> > > }
> > > catch { }
> > > }
> > > }

>
> > > I did a quick search on this and only found the following from Chris
> > > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
> > > version I am using does not have a reference to ndisAccess and the
> > > class is only 229 lines. it does have a RefreshList function with no
> > > need to close any Handles.
> > > -----------

>
> > > There is a leak in AccessPointCollection, near line 329 in RefreshList
> > > ().
> > > You need to add the following:

>
> > > FileEx.CloseHandle( ndisAccess );

>
> > > before leaving that method.

>
> > > I'm unable to find anything else actually leaking. All of the managed
> > > arrays, I would think, should be getting freed when the garbage
> > > collector
> > > decides that it's time. There's very little, if any, unmanaged memory
> > > allocated when that series of steps is performed, so there isn't a lot
> > > of
> > > room for things to get lost.
> > > -------------- Hide quoted text -

>
> > - Show quoted text -

>
> Prelim results is that it acts the same between 2.3 and 2.1, still
> seems to be dropping in 200K buckets.
>
> I will know more tomorrow.- Hide quoted text -
>
> - Show quoted text -


Hello Paul,
I am using INetworkInterface, WirelessZeroConfigNetworkInterface, and
NetworkInformation.AccessPoint and do not see a close or dispose
function on any of them.?


 
Reply With Quote
 
Chris Tacke, MVP
Guest
Posts: n/a
 
      16th Jul 2009
And, unfortunately, I'm leaving on vacation in an hour, so the earliest it's
going to happen on my end would be August.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%(E-Mail Removed)...
> OK, it appears to me that there may a missing deallocation for the raw
> data portion of the INTF_ENTRY struct in the AccessPointCollection methods
> for the allocation near line 173. I think that Chris would have to
> identify and apply a fix.
>
> Paul T.
>
> ".net CF'er" <(E-Mail Removed)> wrote in message
> news:90f24a41-b8b0-4ee9-8080-(E-Mail Removed)...
> On Jul 15, 4:13 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
> no instrument no spam DOT com> wrote:
>> Are you, by any chance, not disposing of something, an AccessPoint or an
>> Adapter, when you're done with it? That sounds like a case where a large
>> structure that one of those classes allocated to get SSID information
>> might
>> not get thrown away unless you call Dispose(), Close() or something of
>> that
>> nature, possibly because you are storing things in an array for later use
>> or
>> something.
>>
>> Paul T.
>>
>> ".net CF'er" <jderu...@gmail.com> wrote in message
>>
>> news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)...
>> On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
>> wrote:
>>
>>
>>
>>
>>
>> > Have you tried anything newer? We're already at version 2.3, and we
>> > made a
>> > lot of changes and did a lot of fixes around WiFi in the 2.3 release.

>>
>> > --

>>
>> > Chris Tacke, Embedded MVP
>> > OpenNETCF Consulting
>> > Giving back to the embedded communityhttp://community.OpenNETCF.com

>>
>> > ".net CF'er" <jderu...@gmail.com> wrote in message

>>
>> >news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...

>>
>> > > Hello All, I think I have narrowed a memory leak down to this code. I
>> > > am using OpenNETCF.Net Version 2.1.
>> > > As you can see, I am really doing nothing in the following code
>> > > accept
>> > > getting the current adapters preferredAccessPoint collection. I plan
>> > > on digging into this code this weekend/next week but wanted to throw
>> > > it out on the forum in hopes others have a solution. The pattern
>> > > appears to be a 200K drop in available virtual every ~ 15 calls to
>> > > the
>> > > function that runs the code below. A perfmon diff shows no
>> > > accumulations of objects in managed code. It will run until the exe
>> > > eats up all 32MB.

>>
>> > > // Add other preferred access points
>> > > foreach (AccessPoint accessPoint in
>> > > currentAdapter.PreferredAccessPoints)
>> > > {
>> > > if (!results.ContainsKey
>> > > (accessPoint.Name))
>> > > {
>> > > try
>> > > {
>> > > results.Add
>> > > (accessPoint.Name,null);
>> > > }
>> > > catch { }
>> > > }
>> > > }

>>
>> > > I did a quick search on this and only found the following from Chris
>> > > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
>> > > version I am using does not have a reference to ndisAccess and the
>> > > class is only 229 lines. it does have a RefreshList function with no
>> > > need to close any Handles.
>> > > -----------

>>
>> > > There is a leak in AccessPointCollection, near line 329 in
>> > > RefreshList
>> > > ().
>> > > You need to add the following:

>>
>> > > FileEx.CloseHandle( ndisAccess );

>>
>> > > before leaving that method.

>>
>> > > I'm unable to find anything else actually leaking. All of the managed
>> > > arrays, I would think, should be getting freed when the garbage
>> > > collector
>> > > decides that it's time. There's very little, if any, unmanaged memory
>> > > allocated when that series of steps is performed, so there isn't a
>> > > lot
>> > > of
>> > > room for things to get lost.
>> > > -------------- Hide quoted text -

>>
>> > - Show quoted text -

>>
>> Prelim results is that it acts the same between 2.3 and 2.1, still
>> seems to be dropping in 200K buckets.
>>
>> I will know more tomorrow.- Hide quoted text -
>>
>> - Show quoted text -

>
> Hello Paul,
> I am using INetworkInterface, WirelessZeroConfigNetworkInterface, and
> NetworkInformation.AccessPoint and do not see a close or dispose
> function on any of them.?
>


 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Jul 2009
Hmmm. Well, I'll try to take a look at it and at least suggest a fix for
the interim in the field. If .net CFer has the code, that should allow
things to be fixed for now, at least.

Enjoy the vacation!
Paul T.

"Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in message
news:AF105300-FBF2-448A-908A-(E-Mail Removed)...
> And, unfortunately, I'm leaving on vacation in an hour, so the earliest
> it's going to happen on my end would be August.
>
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Giving back to the embedded community
> http://community.OpenNETCF.com
>
>
> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> com> wrote in message news:%(E-Mail Removed)...
>> OK, it appears to me that there may a missing deallocation for the raw
>> data portion of the INTF_ENTRY struct in the AccessPointCollection
>> methods for the allocation near line 173. I think that Chris would have
>> to identify and apply a fix.
>>
>> Paul T.
>>
>> ".net CF'er" <(E-Mail Removed)> wrote in message
>> news:90f24a41-b8b0-4ee9-8080-(E-Mail Removed)...
>> On Jul 15, 4:13 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
>> no instrument no spam DOT com> wrote:
>>> Are you, by any chance, not disposing of something, an AccessPoint or an
>>> Adapter, when you're done with it? That sounds like a case where a large
>>> structure that one of those classes allocated to get SSID information
>>> might
>>> not get thrown away unless you call Dispose(), Close() or something of
>>> that
>>> nature, possibly because you are storing things in an array for later
>>> use or
>>> something.
>>>
>>> Paul T.
>>>
>>> ".net CF'er" <jderu...@gmail.com> wrote in message
>>>
>>> news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)...
>>> On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
>>> wrote:
>>>
>>>
>>>
>>>
>>>
>>> > Have you tried anything newer? We're already at version 2.3, and we
>>> > made a
>>> > lot of changes and did a lot of fixes around WiFi in the 2.3 release.
>>>
>>> > --
>>>
>>> > Chris Tacke, Embedded MVP
>>> > OpenNETCF Consulting
>>> > Giving back to the embedded communityhttp://community.OpenNETCF.com
>>>
>>> > ".net CF'er" <jderu...@gmail.com> wrote in message
>>>
>>> >news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...
>>>
>>> > > Hello All, I think I have narrowed a memory leak down to this code.
>>> > > I
>>> > > am using OpenNETCF.Net Version 2.1.
>>> > > As you can see, I am really doing nothing in the following code
>>> > > accept
>>> > > getting the current adapters preferredAccessPoint collection. I plan
>>> > > on digging into this code this weekend/next week but wanted to throw
>>> > > it out on the forum in hopes others have a solution. The pattern
>>> > > appears to be a 200K drop in available virtual every ~ 15 calls to
>>> > > the
>>> > > function that runs the code below. A perfmon diff shows no
>>> > > accumulations of objects in managed code. It will run until the exe
>>> > > eats up all 32MB.
>>>
>>> > > // Add other preferred access points
>>> > > foreach (AccessPoint accessPoint in
>>> > > currentAdapter.PreferredAccessPoints)
>>> > > {
>>> > > if (!results.ContainsKey
>>> > > (accessPoint.Name))
>>> > > {
>>> > > try
>>> > > {
>>> > > results.Add
>>> > > (accessPoint.Name,null);
>>> > > }
>>> > > catch { }
>>> > > }
>>> > > }
>>>
>>> > > I did a quick search on this and only found the following from Chris
>>> > > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
>>> > > version I am using does not have a reference to ndisAccess and the
>>> > > class is only 229 lines. it does have a RefreshList function with no
>>> > > need to close any Handles.
>>> > > -----------
>>>
>>> > > There is a leak in AccessPointCollection, near line 329 in
>>> > > RefreshList
>>> > > ().
>>> > > You need to add the following:
>>>
>>> > > FileEx.CloseHandle( ndisAccess );
>>>
>>> > > before leaving that method.
>>>
>>> > > I'm unable to find anything else actually leaking. All of the
>>> > > managed
>>> > > arrays, I would think, should be getting freed when the garbage
>>> > > collector
>>> > > decides that it's time. There's very little, if any, unmanaged
>>> > > memory
>>> > > allocated when that series of steps is performed, so there isn't a
>>> > > lot
>>> > > of
>>> > > room for things to get lost.
>>> > > -------------- Hide quoted text -
>>>
>>> > - Show quoted text -
>>>
>>> Prelim results is that it acts the same between 2.3 and 2.1, still
>>> seems to be dropping in 200K buckets.
>>>
>>> I will know more tomorrow.- Hide quoted text -
>>>
>>> - Show quoted text -

>>
>> Hello Paul,
>> I am using INetworkInterface, WirelessZeroConfigNetworkInterface, and
>> NetworkInformation.AccessPoint and do not see a close or dispose
>> function on any of them.?
>>

>



 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Jul 2009
There are actually a few places where INTF_ENTRY structures are allocated
but not Dispose-ed. I'll give a list and you can try to find them and fix
them:

1. NetworkInformation.AccessPointCollection near line 234 there should be a
call to ie.Dispose().

2. NetworkInformation.WirelessZeroConfigNetworkInterface near line 102, in
the if ( retVal > 0 ) case, entry.Dispose() needs to be called, as it is in
the other case.

3. NetworkInformation.WirelessZeroConfigNetworkInterface near line 117, in
the if (WZC.QueryAdapter(this.Name, out entry) == 0) case, there are
actually two bugs. You need to add a line like this:

// PGT: Need to check the state of the flag to determine
// what to return.
bool ret = ((entry.dwCtlFlags & (uint)INTF_FLAGS.INTF_FALLBACK) != 0);

followed by one like this:

// PGT: Need to free it!
entry.Dispose();

That's what I've spotted so far. The rest of the INTF_ENTRY uses, at least,
seem to be handled correctly. I'm leaving a little program running for a
while to see if there are any other obvious leaks.

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%(E-Mail Removed)...
> Hmmm. Well, I'll try to take a look at it and at least suggest a fix for
> the interim in the field. If .net CFer has the code, that should allow
> things to be fixed for now, at least.
>
> Enjoy the vacation!
> Paul T.
>
> "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in message
> news:AF105300-FBF2-448A-908A-(E-Mail Removed)...
>> And, unfortunately, I'm leaving on vacation in an hour, so the earliest
>> it's going to happen on my end would be August.
>>
>>
>> --
>>
>> Chris Tacke, Embedded MVP
>> OpenNETCF Consulting
>> Giving back to the embedded community
>> http://community.OpenNETCF.com
>>
>>
>> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
>> DOT com> wrote in message news:%(E-Mail Removed)...
>>> OK, it appears to me that there may a missing deallocation for the raw
>>> data portion of the INTF_ENTRY struct in the AccessPointCollection
>>> methods for the allocation near line 173. I think that Chris would have
>>> to identify and apply a fix.
>>>
>>> Paul T.
>>>
>>> ".net CF'er" <(E-Mail Removed)> wrote in message
>>> news:90f24a41-b8b0-4ee9-8080-(E-Mail Removed)...
>>> On Jul 15, 4:13 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
>>> no instrument no spam DOT com> wrote:
>>>> Are you, by any chance, not disposing of something, an AccessPoint or
>>>> an
>>>> Adapter, when you're done with it? That sounds like a case where a
>>>> large
>>>> structure that one of those classes allocated to get SSID information
>>>> might
>>>> not get thrown away unless you call Dispose(), Close() or something of
>>>> that
>>>> nature, possibly because you are storing things in an array for later
>>>> use or
>>>> something.
>>>>
>>>> Paul T.
>>>>
>>>> ".net CF'er" <jderu...@gmail.com> wrote in message
>>>>
>>>> news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)...
>>>> On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
>>>> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> > Have you tried anything newer? We're already at version 2.3, and we
>>>> > made a
>>>> > lot of changes and did a lot of fixes around WiFi in the 2.3 release.
>>>>
>>>> > --
>>>>
>>>> > Chris Tacke, Embedded MVP
>>>> > OpenNETCF Consulting
>>>> > Giving back to the embedded communityhttp://community.OpenNETCF.com
>>>>
>>>> > ".net CF'er" <jderu...@gmail.com> wrote in message
>>>>
>>>> >news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...
>>>>
>>>> > > Hello All, I think I have narrowed a memory leak down to this code.
>>>> > > I
>>>> > > am using OpenNETCF.Net Version 2.1.
>>>> > > As you can see, I am really doing nothing in the following code
>>>> > > accept
>>>> > > getting the current adapters preferredAccessPoint collection. I
>>>> > > plan
>>>> > > on digging into this code this weekend/next week but wanted to
>>>> > > throw
>>>> > > it out on the forum in hopes others have a solution. The pattern
>>>> > > appears to be a 200K drop in available virtual every ~ 15 calls to
>>>> > > the
>>>> > > function that runs the code below. A perfmon diff shows no
>>>> > > accumulations of objects in managed code. It will run until the exe
>>>> > > eats up all 32MB.
>>>>
>>>> > > // Add other preferred access points
>>>> > > foreach (AccessPoint accessPoint in
>>>> > > currentAdapter.PreferredAccessPoints)
>>>> > > {
>>>> > > if (!results.ContainsKey
>>>> > > (accessPoint.Name))
>>>> > > {
>>>> > > try
>>>> > > {
>>>> > > results.Add
>>>> > > (accessPoint.Name,null);
>>>> > > }
>>>> > > catch { }
>>>> > > }
>>>> > > }
>>>>
>>>> > > I did a quick search on this and only found the following from
>>>> > > Chris
>>>> > > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
>>>> > > version I am using does not have a reference to ndisAccess and the
>>>> > > class is only 229 lines. it does have a RefreshList function with
>>>> > > no
>>>> > > need to close any Handles.
>>>> > > -----------
>>>>
>>>> > > There is a leak in AccessPointCollection, near line 329 in
>>>> > > RefreshList
>>>> > > ().
>>>> > > You need to add the following:
>>>>
>>>> > > FileEx.CloseHandle( ndisAccess );
>>>>
>>>> > > before leaving that method.
>>>>
>>>> > > I'm unable to find anything else actually leaking. All of the
>>>> > > managed
>>>> > > arrays, I would think, should be getting freed when the garbage
>>>> > > collector
>>>> > > decides that it's time. There's very little, if any, unmanaged
>>>> > > memory
>>>> > > allocated when that series of steps is performed, so there isn't a
>>>> > > lot
>>>> > > of
>>>> > > room for things to get lost.
>>>> > > -------------- Hide quoted text -
>>>>
>>>> > - Show quoted text -
>>>>
>>>> Prelim results is that it acts the same between 2.3 and 2.1, still
>>>> seems to be dropping in 200K buckets.
>>>>
>>>> I will know more tomorrow.- Hide quoted text -
>>>>
>>>> - Show quoted text -
>>>
>>> Hello Paul,
>>> I am using INetworkInterface, WirelessZeroConfigNetworkInterface, and
>>> NetworkInformation.AccessPoint and do not see a close or dispose
>>> function on any of them.?
>>>

>>

>
>



 
Reply With Quote
 
.net CF'er
Guest
Posts: n/a
 
      17th Jul 2009
On Jul 16, 11:23*am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
> Hmmm. *Well, I'll try to take a look at it and at least suggest a fix for
> the interim in the field. *If .net CFer has the code, that should allow
> things to be fixed for now, at least.
>
> Enjoy the vacation!
> Paul T.
>
> "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in messagenews:AF105300-FBF2-448A-908A-(E-Mail Removed)...
>
>
>
> > And, unfortunately, I'm leaving on vacation in an hour, so the earliest
> > it's going to happen on my end would be August.

>
> > --

>
> > Chris Tacke, Embedded MVP
> > OpenNETCF Consulting
> > Giving back to the embedded community
> >http://community.OpenNETCF.com

>
> > "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> > com> wrote in messagenews:%(E-Mail Removed)...
> >> OK, it appears to me that there may a missing deallocation for the raw
> >> data portion of the INTF_ENTRY struct in the AccessPointCollection
> >> methods for the allocation near line 173. *I think that Chris would have
> >> to identify and apply a fix.

>
> >> Paul T.

>
> >> ".net CF'er" <jderu...@gmail.com> wrote in message
> >>news:90f24a41-b8b0-4ee9-8080-(E-Mail Removed)....
> >> On Jul 15, 4:13 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
> >> no instrument no spam DOT com> wrote:
> >>> Are you, by any chance, not disposing of something, an AccessPoint oran
> >>> Adapter, when you're done with it? That sounds like a case where a large
> >>> structure that one of those classes allocated to get SSID information
> >>> might
> >>> not get thrown away unless you call Dispose(), Close() or something of
> >>> that
> >>> nature, possibly because you are storing things in an array for later
> >>> use or
> >>> something.

>
> >>> Paul T.

>
> >>> ".net CF'er" <jderu...@gmail.com> wrote in message

>
> >>>news:0efca325-ad8b-4a59-ad71-(E-Mail Removed)....
> >>> On Jul 11, 10:48 pm, "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com>
> >>> wrote:

>
> >>> > Have you tried anything newer? We're already at version 2.3, and we
> >>> > made a
> >>> > lot of changes and did a lot of fixes around WiFi in the 2.3 release.

>
> >>> > --

>
> >>> > Chris Tacke, Embedded MVP
> >>> > OpenNETCF Consulting
> >>> > Giving back to the embedded communityhttp://community.OpenNETCF.com

>
> >>> > ".net CF'er" <jderu...@gmail.com> wrote in message

>
> >>> >news:13a2a82a-8620-475f-8fd6-(E-Mail Removed)...

>
> >>> > > Hello All, I think I have narrowed a memory leak down to this code.
> >>> > > I
> >>> > > am using OpenNETCF.Net Version 2.1.
> >>> > > As you can see, I am really doing nothing in the following code
> >>> > > accept
> >>> > > getting the current adapters preferredAccessPoint collection. I plan
> >>> > > on digging into this code this weekend/next week but wanted to throw
> >>> > > it out on the forum in hopes others have a solution. The pattern
> >>> > > appears to be a 200K drop in available virtual every ~ 15 calls to
> >>> > > the
> >>> > > function that runs the code below. A perfmon diff shows no
> >>> > > accumulations of objects in managed code. It will run until the exe
> >>> > > eats up all 32MB.

>
> >>> > > // Add other preferred access points
> >>> > > foreach (AccessPoint accessPoint in
> >>> > > currentAdapter.PreferredAccessPoints)
> >>> > > {
> >>> > > if (!results.ContainsKey
> >>> > > (accessPoint.Name))
> >>> > > {
> >>> > > try
> >>> > > {
> >>> > > results.Add
> >>> > > (accessPoint.Name,null);
> >>> > > }
> >>> > > catch { }
> >>> > > }
> >>> > > }

>
> >>> > > I did a quick search on this and only found the following from Chris
> >>> > > T. The difference is this guy was using NetCF ver 1.4 and the 2.1
> >>> > > version I am using does not have a reference to ndisAccess and the
> >>> > > class is only 229 lines. it does have a RefreshList function withno
> >>> > > need to close any Handles.
> >>> > > -----------

>
> >>> > > There is a leak in AccessPointCollection, near line 329 in
> >>> > > RefreshList
> >>> > > ().
> >>> > > You need to add the following:

>
> >>> > > FileEx.CloseHandle( ndisAccess );

>
> >>> > > before leaving that method.

>
> >>> > > I'm unable to find anything else actually leaking. All of the
> >>> > > managed
> >>> > > arrays, I would think, should be getting freed when the garbage
> >>> > > collector
> >>> > > decides that it's time. There's very little, if any, unmanaged
> >>> > > memory
> >>> > > allocated when that series of steps is performed, so there isn't a
> >>> > > lot
> >>> > > of
> >>> > > room for things to get lost.
> >>> > > -------------- Hide quoted text -

>
> >>> > - Show quoted text -

>
> >>> Prelim results is that it acts the same between 2.3 and 2.1, still
> >>> seems to be dropping in 200K buckets.

>
> >>> I will know more tomorrow.- Hide quoted text -

>
> >>> - Show quoted text -

>
> >> Hello Paul,
> >> I am using INetworkInterface, WirelessZeroConfigNetworkInterface, and
> >> NetworkInformation.AccessPoint and do not see a close or dispose
> >> function on any of them.?- Hide quoted text -

>
> - Show quoted text -


It looks like the RAW_DATA struct is not being disposed in all the
places it is being used. Going to look at 2.1.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ICS xp host+ vista client via wireless router as accesspoint pafos Windows Vista Networking 3 16th Aug 2008 12:08 PM
How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one it leaks memory. How to do the OCR and then clean up so that my app doesnt leak memory? DR Microsoft Dot NET 1 4th Feb 2008 11:43 PM
How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one it leaks memory. How to do the OCR and then clean up so that my app doesnt leak memory? DR Microsoft Dot NET Framework 1 4th Feb 2008 11:41 PM
Get the SSID of the current connected AccessPoint Nils Hulsch Microsoft C# .NET 0 23rd Jun 2007 04:30 PM
[OpenNETCF.Net] Get signal strength from AccessPoint mielmonster Microsoft Dot NET Compact Framework 8 20th May 2004 04:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 PM.