Electric-Coin-Company / zcash-swift-wallet-sdk

iOS light client Framework proof-of-concept
MIT License
37 stars 33 forks source link

Memory consumption is high while syncing #1016

Closed Chlup closed 1 year ago

Chlup commented 1 year ago

@pacu discovered this while reviewing #1009. After some debugging I found out that same happens in the main branch. So it's not related to the parallel downloading.

Chlup commented 1 year ago

This is the stack trace that allocates most of the memory:

Screenshot 2023-05-02 at 12 07 05
Chlup commented 1 year ago

It looks like that this is problem only when running the SDK in the iOS simulator. On real device (when I run sync in the Sample app) memory consumption stops at ~148MB and then it is slowly decreasing and stops around 60MB. It is super strange. But it also means that it doesn't affect any real user.

Screenshot 2023-05-03 at 12 37 34
pacu commented 1 year ago

shall we open a ticket in Swift-GRPC itself?

tw0po1nt commented 1 year ago

@pacu I'm at the point with the secant version of nighthawk that I am actually successfully creating and importing wallets. However, whenever I try to import an wallet from a bit ago (around 270,000 blocks ago) and run it on device (iPhone SE 3rd generation, iOS 16.3.1), my memory is ballooning to the point where the system kills it. So I do think this may be an issue beyond the simulator.

pacu commented 1 year ago

@pacu I'm at the point with the secant version of nighthawk that I am actually successfully creating and importing wallets. However, whenever I try to import an wallet from a bit ago (around 270,000 blocks ago) and run it on device (iPhone SE 3rd generation, iOS 16.3.1), my memory is ballooning to the point where the system kills it. So I do think this may be an issue beyond the simulator.

thanks for reporting this. We are still chasing this down, any additional context or hints are welcome!

Chlup commented 1 year ago

@tw0po1nt Can you please run your app from the Xcode and then make screenshot of memory consumption graph? So we know what is exactly happening on your device?

pacu commented 1 year ago

Tested on iPhone 7 that workaround on 0.22.0-beta works properly