I am profiling my app on an iPhone. I am creating a LOT of UIWebView and sticking them in a MonoTouch.Dialog Table (lets say 1000). I have a button that clears out the table section and disposes the webviews and any reference to any of the WebViews.
I notice with Mono Profile, that the instances of UIWebview goes down to zero (as it should). However, if I do the same test using Instruments (Allocations), it shows that the number of “live” Webviews never decreases and the memory never recovers. I even tried a GC.Collect and it made no difference.
I also see that Mono profile says that total ram being used is aroun 1.5 meg, when in Instruments shows around 5meg.
The first item concerns me more since it appears that I am unable to recover that memory and destroy all those instances. Am I reading this wrong or is there some other issue? Thanks.
If the number of UIWebView instances go down in the Mono profiler, but not in Instruments, it means native code is holding a reference to those instances, preventing them from getting released.
I suggest you enable the “Record reference count” option in the Allocations instrument, and then investigate the retainCount when the UIWebView instances only show up in Instruments – you need to pair each retain call with a release call (but there will be at least one you can’t pair up, and that’s the one you’re looking for). At this point you need to figure out why that retain call doesn’t have a corresponding release call.
Neither the Mono profile nor the Allocations instrument actually tell you the total amount of ram being used (and they measure different things which is why the number is different). The Mono profiler only measures managed objects, while the Allocations object measures most (but not all) native allocations in addition to the managed ones.