My iPad app was developed in MonoTouch because I wanted to avoid the entire memory admiral, but it doesn't seem to be that way. Everything worked fine on the simulator, but when I tested my application on the device, I was horrified to find that it quickly gets killed by the OS after some memory warnings. My application is a simple image browser, it downloads some PNG images and displays them using some UIView inside a UIScrollView, loading the next or previous one when it gets touched. It works great on a simulator. But on the device, after loading and unloading about 6-11 images, it starts to receive warnings about memory, and then suddenly the process is destroyed. I checked all my instinctive cycles and I will correctly delete all links before uploading new images.
So, I started working with tools and began to profile the memory allocation of my application on the iPad. There I found that Live bytes are only about 5-9 MB, only what I expected, but for some strange reason, the amount of dead memory is almost not collected, because after allocating about 50 MB (less than 5-9 MB Live Bytes), he is killed! Here is a screenshot of my application’s profiling session:

And here is the sequence of heapshots sequences:

There are also small leaks, but I think they are not so large as to be to blame. These are all 48 bytes of leakage from strdup, a known issue when releasing UIScrollView in iOS 5.1:

, , Live Bytes 5 , , 50 iPad 314 iPhone4S, :

- , , , ? monotouch? - , ? , ? , .
//:
void StartImageLoadingThread()
{
tokenSource = new CancellationTokenSource ();
token = tokenSource.Token;
Task task1 = new Task( () => PerformLoadImageTask(token),token);
task1.Start();
}
void PerformLoadImageTask(CancellationToken token)
{
if (token.IsCancellationRequested)
{
Console.WriteLine("Task {0}: Cancelling", Task.CurrentId);
return;
}
current_uiimage_A = UIImage.FromFileUncached(file_name);
page_A_image_view.Image = current_uiimage_A;
}
void UnloadImageAFromMemory()
{
page_A_image_view.Image = null;
current_uiimage_A.Dispose();
current_uiimage_A = null;
}
, ? , , , ? , GC, , , . , .
- Xamarin .
,
!
UPDATE:
uiviews, Live Bytes 9 5 , - , , .
2:
, , ! , MonoTouch , UIImages . , , , ! ?