I'm trying to debug a potential javascript memory leak on iOS. My approach (was) to monitor Mobile Safari on my iPad using Instruments, but there's a problem: no matter what process I attach Instruments to, I get no data at all. After setting up the items to watch and starting the monitor, it runs along happily, but shows no memory usage, no CPU usage, nothing. Is there something I need to do with my iPad or Instruments to enable collection of this data?
I also had this issue with xCode 6 where the instruments would show like it's recording data although there was no actual data presented or collected.
Restarting my Mac Mini, restarting xCode, cleaning the build and disconnecting and connecting my iPad did not solve this issue.
However, my other devices were profiling just fine.
The solution I found is to reboot the iPad. (You reboot your device holding the home button and the power button for a few seconds. Then to turn it on again you press the power button).
This solved this issue and I was told it can solve other xCode related issues like when your program keep running on Debug even when you run it on Release.
Hope this helps.
Related
I have some questions about the performance of a react native app.
I'm developing a react native app (RN 0.62.2). I'm testing on various IOS simulators as well as on a real device (iPhone 7, ios 13.3).
I'm mostly using the simulator because it's the fastest way to check the output of the code, but when I'm testing on my iPhone 7, I see some performance issues.
First of all: I'm using react navigation. When I open the perf monitor on the simulator and I navigate to a new screen (in the same stack navigator), the JS thread drops with about 6-8 frames (from 60 to 52-54). On the real device with 18-20 frames (from 60 to 40-42). I navigate to the exact same screen.
Secondly, I load local images through require. On the simulator, they appear almost instantly. On the real device, it takes some time before they appear. For example, I have a screen with a background image. On the simulator, it's instantly shown. On the real device however, it takes about a second to load.
I'm using a lot of animations in my app. I'm using reanimated to run the animations on the UI thread. In the simulator, they all work very smoothly, but on the real device, it seems like they are having some issues. They're not that smooth as on the simulator.
Another thing: when entering some text in a textinput (text is stored in a useState-variable while typing through onChangeText={v => setValue(v)}. Frame drops about 6-8 frames on the simulator, but again around 18-20 frames on the real device.
My question now is: what could possibly be the reason for this difference in performance? I've come up with some possible answers, is one (or more of them) correct?
Reason 1: metro server
I'm testing on the real device, so the react native code is still on my laptop. The app is not running on my phone yet, so all request go through the cable which connects my phone to my laptop. This results in some lag.
Reason 2: old device
My iphone 7 is old. I'm running ios 13.3 but the iphone is almost 4 years old. However, when I test on an iphone 7 simulator (ios 11.4), it all works smoothly.
Also I noticed something weird: running the same app in the simulator consumes about the double of RAM memory then on the real device. In the perf monitor on the simulator, when I open the app, or I do some actions, there is more RAM memory used than on the real device (around 30-40 mb, sometimes around 70-80 mb, depeding on the simulator type and ios version).
I have not tested it with a release build yet because my app is far from done. Is there a performance difference between an app testing through the metro server and a release build?
Edit:
I've tested the release build instead of the debug build on my real device. I see a better performance than in the debug build, so that's good. The problem now is: I can't check the perf monitor. Does someone know a good tool to check the performance of a release build?
Great question!
Not aware of any means to run debugger against a Release build. That said - you can run a Debug build on your physical device.
Connect device to Macbook
Open ios/.xcworkspace in XCode
Choose your device and Product -> Run
You'll have access to all the typical debugging niceties - Inspector, debugger, Performance monitor. Assume your Release builds will run faster than Debug builds.
I have an app that is available on AppStore, it is a biological recognition app, so there's lots of C/C++ code in this app, and it goes well on iOS7 to iOS9, but when I tested in on iOS10, it always crashed dued to memory issue after several trials, I tried the Allocation instrument, not much leaks.
When I tested it in xCode, I found something interesting(I already shut down every app that run background), the memory usage of other process increased dramatically on iOS 10.
iOS10_iPhone5s
But it didn't increase so much on iOS9:
iOS10_iPhone5
So I have several questions here:
what's in other processes, it should be the apps that run background, but why the memory usage increased even I shut down all the other apps?
why I can only reproduce this issue on iOS10? and it runs well on iOS7-iOS9.
Can anybody help me? thank you.
"Other Processes" includes literally every other program that is currently running on your Mac. That number has nothing to do with the simulator. It does not measure processes that run in the simulator.
If you run iOS Simulator Xcode shows memory stats from your Mac.
Please refer this as well
Running out of memory in 'Other Processes' in Usage Comparion Xcode iOS9
iOS Memory Management -- Other Processes RAM Increasing
We are testing our app on several iPhone 6 Pluses, and at some point we are using GPUImage to capture some images. On my device, it works fine, but on my friend's device, it causes app to crash and Xcode to lose connection to device. It's not like an exception where you hit a breakpoint. Connection to device is lost completely for a split second, just as we've quickly unplugged and replugged the lightning cable (no, we haven't, obviously). There are no errors or warnings at Xcode console, it's exactly like we've unplugged the device, therefore I have no idea why the error occurs. Other than that, the app works normally, and if there are crashes, it 'crashes' normally (hitting a breakpoint on Xcode normally). The bug apparently happens only on camera launch and/or when user takes a photo. Why would that happen? Is it a hardware issue (the device's camera works normally though), or if not, what can I do to find the cause of the problem?
I would suggest taking a look at any memory issues that may be causing the crash. I'm having a similar problem and determined that I was having memory problems by assessing Allocations while profiling the app using Instruments:
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction/Introduction.html
I´m looking for memory leaks usign the Instrument (profile). When I run my app on the device, the last vesion of the app is not showed, the Instruments show an old version of my app. If I use the simulator every thing is fine.
Any idea about that problem?
Best regards
I'm working on an app that works fine on all devices (all the way back to 3.0 and the first iPhone in fact). If I profile useing'Activity Monitor' instrument (Memory Monitor) tool the app runs fine, with no crashes, and no excessive memory usage reported.
However, when I run it in Profile mode with the 'Allocations / leaks' tool selected, on iPad 1, I get lots of memory warnings in quick succession followed by a crash (about a second after all the memory warnings fire off, it crashes), but this ONLY happens when running with the allocations / leaks monitor enabled.
I need to find out why this is happening. Is there a compatibility issue with iPads and the latest version of instruments and that specific tool? Does it take up an excessive portion of memory?
Thanks in advance,
Stew