Different behaviour when running SL app with/without ANTS-MP

Memory profiling for .NET developers

Moderators: Luke Jefferson, StephenC, AndrewH, melvyn.harbour, james.billings, Laura Morley, dene.boulton

Different behaviour when running SL app with/without ANTS-MP

Postby Hans » Tue Jun 12, 2012 9:11 am

My SL app has a central IDictionary<string, WeakReference> where currently "active" controls are referenced weakly in order to dispatch messages to them by their ID (string). Now, when I open a new view the dictionary grows, lets say by 10 items. When I then close the view, these 10 items need to get away.

So what I did to test this is:
- print dictionary count by clicking a test button
- open a new view (dictionary count increases)
- close the view again
- invoke "GC.Collect(); GC.WaitForPendingFinalizers();" a few times by clicking a test button
- loop over the dictionary and remove all items where the weak reference is not alive anymore
- print dictionary count again (must be the same as above)

Result:
- when i run my SL app with ANTS MP everything works as expected: all newly added items are gone. same dictionary count. perfect!
- but when i run the exact same SL app without ANTS MP, these newly added items remain, since their reference seems to be still alive. unfortunately i cannot find out what references these items because in ANTS it works just fine.

QUESTION:
- what could be the reason for this behaviour? is ANTS MP doing anything special here?

regards,
hans
Hans
 
Posts: 3
Joined: Tue Jun 12, 2012 8:41 am

Postby james.billings » Wed Jun 13, 2012 1:40 pm

The main difference you'll observe with ANTS is that when you take a snapshot, we force a GC. Based on your test steps it does sound like you're calling this yourself (GC.Collect()) so it's a little strange; but my guess is that your GC.Collect call is somehow not doing what you expect but the one that ANTS issues does?

I checked on our internal discussions if this had been queried before (another customer observed that with ANTS their objects were cleared up but when calling GC.Collect themselves, they weren't) and the answer was that no, we don't do anything special.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Postby Hans » Wed Jun 13, 2012 4:25 pm

thank you for your reply, james.

indeed, i'm not talking about the GC.Collect() that ANTS issues when taking a snapshot. i'm doing this myself when clicking on a test button. the actual code behind the button is just the two lines:

GC.Collect();
GC.WaitForPendingFinalizers();

as i said, when i click this button while i'm profiling in ANTS, things get cleaned up nicely (without taking snapshots etc). clicking this button outside of ANTS doesn't seem to have any effect. no matter how often and how long i click it.


regarding the other customer you mentioned. was he using SILVERLIGHT as well? is ANTS launching SL with special security stuff etc. ?
Hans
 
Posts: 3
Joined: Tue Jun 12, 2012 8:41 am

Postby james.billings » Wed Jun 13, 2012 5:37 pm

Unfortunately I cannot find the original ticket that the query related to, having done a search for a month or so either side of the time the question was asked, so the only information I have is that we asked the dev-team if ANTS does anything special.

This was slightly different in that taking a snapshot with the memory profiler cleared the objects away whereas the customer calling GC.Collect() in a dispose method did not - they didn't have the equivalent of a test button, although I'm guessing that shouldn't make any difference.

I guess the test here is, does a snapshot clear off your objects even without you clicking your test button? If so, then the problem is perhaps less related to that..?
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Postby Hans » Thu Jun 14, 2012 8:01 am

alright, thank you james. i think i'll have to be content with that for the moment. in case you hear anything new, let me know...
Hans
 
Posts: 3
Joined: Tue Jun 12, 2012 8:41 am


Return to ANTS Memory Profiler 7

Who is online

Users browsing this forum: No registered users and 0 guests