Bug 31293 - Memory Leak When Using A Video Asset
Summary: Memory Leak When Using A Video Asset
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.10
Hardware: PC Mac OS
: Normal normal
Target Milestone: 8.13 (C6 alpha)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-22 13:38 UTC by Jimmy [MSFT]
Modified: 2015-07-31 14:22 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jimmy [MSFT] 2015-06-22 13:38:23 UTC
*** Overview ***
When using AVAssetImageGenerator to get the dimensions of a video, the video asset is not being cleaned up properly after the method returns and it causes a memory leak in the app.

I tried manually calling Dispose on serval of the AVFoundation objects, but it makes no difference.


*** Steps to Reproduce ***

> I used Instruments and the simulator to observe the app’s memory usage

1. Run the attached sample project
2. Select “UnitTests.exe > VideoUtilsTests”
3. Select “GetThumbnailSize_Test” to run the test
4. The test completes successfully, but an increase in memory usage is observed in Instruments and it does not decrease after the test completes


*** Actual Results ***
The app’s memory usage keeps increasing.


** Expected Results *** 
AVAssets are properly disposed of after they are used to prevent a memory leak.


*** Environment Info ***
=== Xamarin Studio ===

Version 5.9.3 (build 1)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
Runtime:
	Mono 4.0.1 ((detached/ed1d3ec)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010044

=== Apple Developer Tools ===

Xcode 6.3.2 (7718)
Build 6D2105

=== Xamarin.iOS ===

Version: 8.10.1.64 (Business Edition)
Hash: e6ebd18
Branch: master
Build date: 2015-05-21 21:55:09-0400

=== Xamarin.Android ===

Version: 5.1.3.1 (Business Edition)
Android SDK: /Users/jimmygarrido/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.1.64 (Business Edition)

=== Build Information ===

Release ID: 509030001
Git revision: 5a524e1726ed103fdd4fe37e0356f2b35466ce9d
Build date: 2015-06-02 16:35:08-04
Xamarin addins: 51957cfbd06be911b212671ad05c2c6221ac90f9

=== Operating System ===

Mac OS X 10.10.3
Darwin Jimmys-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 2 Rajneesh Kumar 2015-07-01 14:28:58 UTC
I have checked this issue and able to reproduce this. To reproduce this I have followed the steps and instruction provided in bug description.

I observed that the test completes successfully, but an increase in memory usage is observed in Instruments and it does not decrease after the test completes. Please refer the screencast.

Screencast: http://www.screencast.com/t/js0EX7r18q7u

Ide Logs: https://gist.github.com/Rajneesh360Logica/dcaec8e10c8d50ae829e
Build Output: https://gist.github.com/Rajneesh360Logica/8b6348aba262e8d98cb6
Application output: https://gist.github.com/Rajneesh360Logica/4853eb04e5bbdba900a6
Device logs: https://gist.github.com/Rajneesh360Logica/edbf15912d382c997845

Environment Info:

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

=== Xamarin.Android ===

Version: 5.1.4.16 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.2.40 (Business Edition)
Hash: ff5adaa
Branch: master
Build date: 2015-06-30 11:17:03-0400

=== Xamarin.Mac ===

Version: 2.0.2.40 (Business Edition)

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-07-31 14:22:32 UTC
Fixed.

maccore/master: 67c4ade8d112c0ddd9d2e9a5f369eeeaa4a7e38f