kos
kos

Reputation: 269

leaked object in instruments even when running HelloWorld_IPhone monotouch

My application permanently receives memory warnings and I really cannot find what is causing it. I was getting a major leak even if I was stripping the app to the bare minimum. So what I thought was to compile the default HelloWorld_IPhone app from the monotouch examples and see whether I get the same leak. It turns out I do. Really confusing me.

enter image description here

The leak appears just after the app launches (red bar is filling the whole column).

leaked object: Malloc 16 Bytes, Responsible Library: HelloWorld_IPhone, responsible frame: mono_dl_open

My question is whether this is normal or whether I am missing something?

EDIT: Screenshot of Instruments output when running TweetStation app on my device in debug mode! Same results as my app. Surely something not right here? Screenshot of Instruments output when running TweetStation app on my device

Upvotes: 2

Views: 2238

Answers (2)

miguel.de.icaza
miguel.de.icaza

Reputation: 32694

When trying to debug leaks in unmanaged code with Instruments, what you can do is create an "Allocation" instrument and then make sure that you select the option "Only Track Active Allocations", like this:

Instruments Screenshot
(source: tirania.org)

This only shows the objects that are currently "live" and have not been released. With Mono, you will notice that some objects are kept around until the garbage collector runs. So over time the spikes of allocated objects disappear.

Upvotes: 4

poupou
poupou

Reputation: 43553

I think you're confusing a few different things. Profiling tools tends to shows a lot of data and it's easy to get lost inside all of it.

First the image you linked (I added it to your original question) is showing two things:

  1. The Allocations. That's the Instrument's row you have selected. What it shows is what your application has allocated. You can see a lot of 16 bytes allocations but they are not leaks just because they are shown there.

  2. An alert that shows your application has received a Low Memory Warning. IOW you exhausted the (device/simulator) memory and you're being notified to free up memory (or iOS will kill your application). Again it does not mean there are any (or major) leak(s).

What's not shown in your picture is what's on Instrument's second row (the Leaks). There could be a lot of leaks (but I doubt that for the hello world sample) or only a few.

There are somes cases, inside Mono (e.g. mono_dl_open), where memory is allocated and never freed (because it cannot be, e.g. it would close a required library). This is not generally an issue since the mono runtime can't be unloaded without unloading (i.e. closing) your application (where the memory will all be reclaimed by the operating system).

Anyhow we'll need more details in order to know if this leak (or others) are related with your application memory allocations (or not). If you can either supply them (edit your question here) or attach a sample to a bug report on http://bugzilla.xamarin.com/

Upvotes: 0

Related Questions