Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current memory usage of WKWebView?

In the application I am currently developing I have a requirement to watch the memory usage of the WKWebView. I cannot figure out how to do this. As WKWebView runs seperate from the main app, so getting diagnostics on the main app do not reflect the WKWebView.

Has anyone done this before?

It seems as though on iOS 9 you simply cannot look at other processes running. So that option is out. However I am still not sure, is WKWebview even another process? I notice when launching a new WKWebView, it creates new threads under mach_task_self. So that implies to me the WKWebView is not actually a seperate process, but is in the same process / mach task as the main app. But it's memory is in a different address space.

Is it possible to somehow grab the seperate memory space of the WkWebview through the low level mach and posix methods?

Or is there any other way to get the memory usage of the WkWebView?

like image 746
rygo6 Avatar asked Apr 11 '16 23:04

rygo6


1 Answers

In Xcode, choose "Product" and then select "Profile", after the compilation,it will open Instruments.

Select Activity Monitor and click Choose.

enter image description here

Click the red circle at the top left to start profiling.

enter image description here

Try to find the process named as "com.apple.WebKit", the column of "Real Mem" is what you wanted.

enter image description here

like image 164
patrick kuang Avatar answered Sep 22 '22 14:09

patrick kuang