Windows Phone 8.1 Troubleshooting MediaCapture CapturePhotoToStorageFileAsync Memory Leak

I am creating a universal application for timelapse, which captures a sequence of photos at a given interval. In my timer event, I collect the image and save it in the storage file as follows:

StorageFile file = await appFolder.CreateFileAsync(IMAGE_FILE_ROOT, Windows.Storage.CreationCollisionOption.GenerateUniqueName);
ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();
await MediaCaptureManager.CapturePhotoToStorageFileAsync(imageProperties, file);
ImageFilePaths.Add(file.Path);
file = null;

After successfully capturing about 30 of the highest resolution images (140 at the lowest level) on my phone, I get an Out of Memory exception in the CapturePhotoToStorageFileAsync method.

I tried just taking a photo in InMemoryRandomAccessStream so that I can ellimize the StorageFile API for a leak and it is still flowing.

I have been profiling memory usage with Power Tools WinPhone, and it is constantly growing when photos are taken.

Is there anything I can do to get around this?

:

, :

for (int x = 0; x < 40; x++)
{
    using (IRandomAccessStream memoryStream = new InMemoryRandomAccessStream())
    {
        await MediaCaptureManager.CapturePhotoToStreamAsync(imageProperties, memoryStream);
    }

    await Task.Delay(1000);
}
+4
1

, , !

-, - . MediaCaptureManager, , .

var mediaSettings = new MediaCaptureInitializationSettings
 {
  PhotoCaptureSource = PhotoCaptureSource.Auto,
  StreamingCaptureMode = StreamingCaptureMode.Video,
  AudioDeviceId = string.Empty
 };
0

Source: https://habr.com/ru/post/1569914/


All Articles