Bug 31096 - Memory profiler tracks total allocations
Summary: Memory profiler tracks total allocations
Status: RESOLVED FIXED
Alias: None
Product: Profiler
Classification: Xamarin
Component: General (show other bugs)
Version: unspecified
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Rodrigo Moya
URL:
Depends on:
Blocks:
 
Reported: 2015-06-14 20:02 UTC by david
Modified: 2015-06-26 14:28 UTC (History)
3 users (show)

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


Attachments

Description david 2015-06-14 20:02:45 UTC
There are two aspects to this problem:

1. The memory profiler tracks allocations that aren't in my code. For example, in one small app (less than 1000 lines of my code) I apparently have 459587 System.string allocations after running its code for a few seconds. While this is "information" in a broad sense it is meaningless to me. I have no control over the .NET framework and I'm not interested in how many strings it allocates. I'm interested in _my_ code, since that's why I'm profiling _my_ app. The .NET framework has a bearing on its performance, to be sure, but I need to separate out the things I can control from the things I can't.

2. Since the memory profiler only tracks cumulative allocations, without balancing them out against GC deallocations, I have no way to know how many of these objects are still alive. This is not helpful or useful information. It tells me nothing about how my code is performing. The key question I want an answer for in a mobile app is: does my app fit in memory? The memory profiler in its current form doesn't help answer that question.
Comment 1 Rodrigo Moya 2015-06-15 06:38:22 UTC
We are adding more filtering options so that you will be able to just display allocations in your code/classes, for instance. Right now, yes, we just display everything, which as you say, adds a lot of noise.

About total allocations, what version(s) are you using? More specifically, what header format does the profiler.log (in ~/Library/Logs/Xamarin.Profiler on Mac or %localappdata%\Xamarin/Logs/Xamarin.Profiler on Windows) report? If it is >= 6, we don't display total allocations, but current memory size.

Also, if it's Android, we indeed display current allocations, but there seems to be a problem in the runtime that doesn't report memory ups and downs, as it does for iOS.
Comment 2 david 2015-06-15 20:00:58 UTC
Here's the log file from the run yesterday:

INFO[2015-06-15 09:13:10Z]: ##########################################
INFO[2015-06-15 09:13:10Z]: # Xamarin Profiler version -  0.16-0
INFO[2015-06-15 09:13:10Z]: #  * Arch x86_64
INFO[2015-06-15 09:13:10Z]: ##########################################
DEBUG[2015-06-15 09:13:10Z]: processing command line = 
DEBUG[2015-06-15 09:13:10Z]: 	/Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
DEBUG[2015-06-15 09:13:10Z]: 	--target=/Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app
DEBUG[2015-06-15 09:13:10Z]: 	--device-id=1|8.3
DEBUG[2015-06-15 09:13:14Z]: Creating run for /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app target on device 1|8.3
DEBUG[2015-06-15 09:13:14Z]: Creating connection with iOS device iphone,retina
DEBUG[2015-06-15 09:13:14Z]: Starting profiler on iOS device iphone,retina with log:heapshot=ondemand,sample,alloc,output=/Users/ocadmin/Desktop/8zg8ulg4.4no
DEBUG[2015-06-15 09:13:14Z]: Starting /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch -v -v -v -v -sdkroot "/Applications/Xcode.app/Contents/Developer" -launchsim "/Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app" -sdk 8.3 -argument=-monodevelop-port -argument=53353 -device "iphone,retina"
DEBUG[2015-06-15 09:13:15Z]: iOS app output: Using the specification 'iphone,retina' and SDK '8.3' the following was selected:
DEBUG[2015-06-15 09:13:15Z]: iOS app output:    Runtime: com.apple.CoreSimulator.SimRuntime.iOS-8-3
DEBUG[2015-06-15 09:13:15Z]: iOS app output:    DeviceType: com.apple.CoreSimulator.SimDeviceType.iPhone-4s
DEBUG[2015-06-15 09:13:15Z]: iOS app output: Starting iPhone 4s
DEBUG[2015-06-15 09:13:15Z]: iOS app output: Booting iPhone 4s...
DEBUG[2015-06-15 09:13:15Z]: iOS app output: Booted iPhone 4s successfully.
DEBUG[2015-06-15 09:13:15Z]: iOS app output: Installing /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app with Bundle Identifier com.companyname.dataflowqueue...
DEBUG[2015-06-15 09:13:18Z]: iOS app output: Installed 'com.companyname.dataflowqueue' from /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app
DEBUG[2015-06-15 09:13:20Z]: iOS app output: Shutdown iPhone 4s successfully.
DEBUG[2015-06-15 09:13:20Z]: iOS app output: Launching application
DEBUG[2015-06-15 09:13:23Z]: iOS app output: Application launched. PID = 71109
DEBUG[2015-06-15 09:13:23Z]: iOS app output: Press enter to terminate the application
DEBUG[2015-06-15 09:13:24Z]: Waiting for device iphone,retina to connect
DEBUG[2015-06-15 09:13:24Z]: opening /Users/ocadmin/Desktop/8zg8ulg4.4no
DEBUG[2015-06-15 09:13:24Z]: reading log header
INFO[2015-06-15 09:13:24Z]: read header with format version 8
DEBUG[2015-06-15 09:13:24Z]: reading file /Users/ocadmin/Desktop/8zg8ulg4.4no
DEBUG[2015-06-15 09:13:24Z]: thread Finalizer at -1683898368 loaded
DEBUG[2015-06-15 09:14:25Z]: thread Threadpool worker at 854977024 loaded
DEBUG[2015-06-15 09:14:26Z]: thread Threadpool worker at 851126784 loaded
DEBUG[2015-06-15 09:14:26Z]: thread Threadpool worker at 856033792 loaded
DEBUG[2015-06-15 09:14:35Z]: thread Threadpool worker at 857090560 loaded
DEBUG[2015-06-15 09:14:56Z]: thread Threadpool worker at 858147328 loaded
DEBUG[2015-06-15 09:14:56Z]: thread Threadpool worker at 857090560 loaded
DEBUG[2015-06-15 09:14:57Z]: thread Threadpool worker at 859204096 loaded
DEBUG[2015-06-15 09:14:57Z]: thread Threadpool worker at 860260864 loaded
DEBUG[2015-06-15 09:14:58Z]: thread Threadpool worker at 861317632 loaded
DEBUG[2015-06-15 09:14:59Z]: thread Threadpool worker at 856033792 loaded
DEBUG[2015-06-15 09:15:00Z]: thread Threadpool worker at 857090560 loaded
DEBUG[2015-06-15 09:18:16Z]: Stopping iOS app /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app
DEBUG[2015-06-15 09:18:16Z]: Stopping profiler log reader
DEBUG[2015-06-15 09:18:16Z]: iOS app output: >
DEBUG[2015-06-15 09:18:16Z]: iOS app output: 
DEBUG[2015-06-15 09:18:16Z]: Stopping profiler log reader
DEBUG[2015-06-15 09:18:16Z]: iOS app output: Application Terminated
DEBUG[2015-06-15 09:18:16Z]: iOS app output: 
DEBUG[2015-06-15 09:18:17Z]: LogReader finished
DEBUG[2015-06-15 10:25:00Z]: Creating run for /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app target on device 1|8.3
DEBUG[2015-06-15 10:25:00Z]: Stopping profiler log reader
DEBUG[2015-06-15 10:25:00Z]: Creating connection with iOS device iphone,retina
DEBUG[2015-06-15 10:25:00Z]: Starting /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch -v -v -v -v -sdkroot "/Applications/Xcode.app/Contents/Developer" -launchsim "/Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app" -sdk 8.3 -argument=-monodevelop-port -argument=53709 -device "iphone,retina"
DEBUG[2015-06-15 10:25:00Z]: Starting profiler on iOS device iphone,retina with log:heapshot=ondemand,sample,alloc,output=/Users/ocadmin/Desktop/ea0q75bs.gk3
DEBUG[2015-06-15 10:25:01Z]: iOS app output: Using the specification 'iphone,retina' and SDK '8.3' the following was selected:
DEBUG[2015-06-15 10:25:01Z]: iOS app output:    Runtime: com.apple.CoreSimulator.SimRuntime.iOS-8-3
DEBUG[2015-06-15 10:25:01Z]: iOS app output:    DeviceType: com.apple.CoreSimulator.SimDeviceType.iPhone-4s
DEBUG[2015-06-15 10:25:01Z]: iOS app output: Starting iPhone 4s
DEBUG[2015-06-15 10:25:01Z]: iOS app output: No need to boot (already booted): iPhone 4s
DEBUG[2015-06-15 10:25:01Z]: iOS app output: Installing /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app with Bundle Identifier com.companyname.dataflowqueue...
DEBUG[2015-06-15 10:25:02Z]: iOS app output: Installed 'com.companyname.dataflowqueue' from /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app
DEBUG[2015-06-15 10:25:02Z]: iOS app output: Launching application
DEBUG[2015-06-15 10:25:04Z]: iOS app output: Application launched. PID = 72035
DEBUG[2015-06-15 10:25:04Z]: iOS app output: Press enter to terminate the application
DEBUG[2015-06-15 10:25:04Z]: Waiting for device iphone,retina to connect
DEBUG[2015-06-15 10:25:04Z]: opening /Users/ocadmin/Desktop/ea0q75bs.gk3
DEBUG[2015-06-15 10:25:04Z]: reading log header
INFO[2015-06-15 10:25:04Z]: read header with format version 8
DEBUG[2015-06-15 10:25:04Z]: reading file /Users/ocadmin/Desktop/ea0q75bs.gk3
DEBUG[2015-06-15 10:25:04Z]: thread Finalizer at -1683644416 loaded
DEBUG[2015-06-15 10:25:10Z]: acquiring heapshot via port 53711
DEBUG[2015-06-15 10:25:10Z]: handling heap start at 00:00:06.018
DEBUG[2015-06-15 10:25:11Z]: handling heap end for heapshot Snapshot 0
DEBUG[2015-06-15 10:25:19Z]: acquiring heapshot via port 53711
DEBUG[2015-06-15 10:25:27Z]: handling heap start at 00:00:14.473
DEBUG[2015-06-15 10:25:28Z]: handling heap end for heapshot Snapshot 1
DEBUG[2015-06-15 10:25:33Z]: thread Threadpool worker at 918894080 loaded
DEBUG[2015-06-15 10:25:34Z]: thread Threadpool monitor at 901160104 loaded
DEBUG[2015-06-15 10:25:34Z]: thread Threadpool worker at 914511360 loaded
DEBUG[2015-06-15 10:25:34Z]: thread Threadpool worker at 919950848 loaded
DEBUG[2015-06-15 10:25:37Z]: acquiring heapshot via port 53711
DEBUG[2015-06-15 10:25:43Z]: thread Threadpool worker at 921007616 loaded
DEBUG[2015-06-15 10:26:04Z]: thread Threadpool worker at 922064384 loaded
DEBUG[2015-06-15 10:26:05Z]: thread Threadpool worker at 923121152 loaded
DEBUG[2015-06-15 10:26:05Z]: thread Threadpool worker at 924177920 loaded
DEBUG[2015-06-15 10:26:06Z]: thread Threadpool worker at 925234688 loaded
DEBUG[2015-06-15 10:26:09Z]: thread Threadpool worker at 914511360 loaded
DEBUG[2015-06-15 10:26:09Z]: thread Threadpool worker at 923121152 loaded
DEBUG[2015-06-15 10:26:10Z]: thread Threadpool worker at 925234688 loaded
DEBUG[2015-06-15 10:26:43Z]: Stopping iOS app /Users/ocadmin/Projects/DataflowQueue/iOS/bin/iPhoneSimulator/Debug/DataflowQueue.iOS.app
DEBUG[2015-06-15 10:26:43Z]: Stopping profiler log reader
DEBUG[2015-06-15 10:26:43Z]: iOS app output: >
DEBUG[2015-06-15 10:26:43Z]: iOS app output: Application Terminated
DEBUG[2015-06-15 10:26:43Z]: iOS app output: 
DEBUG[2015-06-15 10:26:43Z]: iOS app output: 
DEBUG[2015-06-15 10:26:43Z]: Stopping profiler log reader
DEBUG[2015-06-15 10:26:44Z]: LogReader finished
Comment 3 Rodrigo Moya 2015-06-16 07:41:27 UTC
This is fixed in our internal builds now, so will be available in the next public release. Note though that the data we use for the charts is what comes from the OS, not the managed code, so it not always reflects the real picture of your app. We are looking at improving this though.
Comment 4 Udham Singh 2015-06-26 14:28:50 UTC
Hi @David,

Could you please check this issue with latest profiler build 0.17 and let us know if you are still getting this issue. You can get latest profiler build from link https://xamarin.com/profiler

Thanks!

Note You need to log in before you can comment on or make changes to this bug.