Memory consumption of Tor client is becoming difficult under iOS 50 MB RAM limitation esp. during startup and with cached info
Summary
Evidence is gathering, that Tor under iOS' network extension memory limitation has trouble building circuits.
See https://github.com/guardianproject/orbot-apple/issues/71#issuecomment-1666818716 and comments before.
I'm playing around with MaxMemInQueues
, but as soon as I uppen it just a little from the 5MB we currently use, Jetsam starts to kill the Network Extension during startup circuit building. (At least in my Austrian environment.)
Starting with cashed information seems to become more and more difficult, too. I already had to put a "clear cache" button at the main screen, because people started to complain so much. I witness this too, now, more and more often.
Do you see any possibility to reduce non-file-backed memory consumption during the startup phase? If this continues to worsen, it will render Orbot iOS unusable. I'm not sure if this is happening due to changes in the network or due to changes in the client code.
If this doesn't get better I will need to consider downgrading Tor to older versions again.
Esp. since I currently released Onion Browser version 3, which now relies on Orbot iOS completely and which currently makes a lot of users unhappy.
There's certain loopholes to the memory accounting in iOS. In this older article I wrote, there's some background to the Jetsam memory accounting:
https://benjaminerhart.com/2018/03/state-of-the-onion-ios/
Esp. helpful might be these:
-
Use file-backed memory / operate on/stream files directly instead of loading everything and juggling that data around a lot. (Maybe we can do that in callbacks we can implement with Objective-C to make use of
NSCache
/NSPurgableData
objects.) -
Provide a method which makes Tor give up unused memory. We could call that from a hook iOS provides.
Steps to reproduce:
- Install Orbot iOS
- Start Orbot
- Witness Tor protocol using left top button.
- If under censored environment, Tor might not be able to build usable circuits at all, because
MaxMemInQueues
is set to 5 MByte. - Override and increase
MaxMemInQueues
in advanced settings. - Witness Network Extension crash during start. (App will show stopped status after a while.)
- In non-restraint environments, manage a complete start. Confirm by surfing to check.torproject.org.
- Stop Orbot.
- Restart Orbot.
- Restart will fail most of the time until "Clear Cache" is pressed.
What is the current bug behavior?
What is the expected behavior?
- Tor limits memory usage during startup phase, so we can increase
MaxMemInQueues
, so constrained environments work, too. - Tor limits memory usage during loading of cached information, so it doesn't reach the 50 MB memory limit.
Environment
tor | 0.4.7.13 |
libevent | 2.1.12 |
OpenSSL | 1.1.1u |
liblzma | 5.4.3 |
iOS 16.6. using Tor.framework
Relevant logs and/or screenshots
https://github.com/guardianproject/orbot-apple/issues/71#issuecomment-1657738391 https://github.com/guardianproject/orbot-apple/issues/71#issuecomment-1666818716