I have an application for the Xamarin android, and it seems that when the application's memory usage reaches a certain threshold from 140 mb to 160 mb, the application will quickly start to take more memory, as in an endless loop. I can see in the debugger output that the garbage collector is constantly trying to free up memory, but it doesn't seem to work. Memory usage will seem limitless. I watched it grow to 500 mb of memory before I decided to kill the application. I NEVER get a memory exception that is really strange. From what I can say, there is no specific part of the code that this is happening, I can be on different screens, and the same thing will happen. I tested several devices, so I know that this is not just a problem with my device. I tried to show some code, but I have no criminals.
Among the components used in my application that may be causing the problem are ReshSharp clients, .net Webclients, the use of bitmaps, TabHost with 3 tabs, a location manager and taking photos through the camera. I am at a standstill on this, any help is much appreciated.
EDIT: Maybe I narrowed down where one of the problems might be. I have camera activity inside the taboo for taking photos. I have a method that is called in the photo after calling the snapshot, after several photos there is a problem. Here is the method
public void OnPictureTaken(byte[] data, global::Android.Hardware.Camera c) { GC.Collect(); Bitmap b = BitmapExtensions.DecodeBitmapFromArray(data, WIDTH, HEIGHT); Matrix matrix = new Matrix(); matrix.SetRotate(RotationDegrees, WIDTH / 2f, HEIGHT / 2f); var bitmapScalled = Bitmap.CreateBitmap(b, 0, 0, WIDTH, HEIGHT, matrix, true); var d = global::Android.OS.Environment.ExternalStorageDirectory.Path + "/MyApp/"; if (!Directory.Exists(d)) Directory.CreateDirectory(d); file = d + Guid.NewGuid().ToString() + ".jpg"; System.IO.StreamWriter sw = new System.IO.StreamWriter(file); bitmapScalled.Compress(Bitmap.CompressFormat.Jpeg, 70, sw.BaseStream); sw.Close(); global::Android.Locations.Location location = CameraLocationManager.GetLastKnownLocation(CameraLocationManager.GetBestProvider(new Criteria() { Accuracy = Accuracy.Fine }, true)); Intent intent = new Intent(this, typeof(EditPhotoActivity)); intent.PutExtra("LastKnownLocation", JsonConvert.SerializeObject(LastKnownLocation)); intent.PutExtra("Filename", file);