getsentry / sentry-unity

Development of Sentry SDK for Unity
https://docs.sentry.io/platforms/unity/
MIT License
210 stars 52 forks source link

Performance problems, Memory growth 30-40MB #1651

Open WeiLingQiang opened 5 months ago

WeiLingQiang commented 5 months ago

Environment

How do you use Sentry? Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?)

Which version of the SDK? v2.0.4

How did you install the package? (Git-URL, Assetstore) Git-URL

Which version of Unity? 2021.3.33f1

Is this happening in Unity (editor) or on a player like Android, iOS, Windows? Android

Steps to Reproduce

  1. Just install and setup the sentry.
  2. Compared with the memory growth before and after access, after it was found that the memory increased by 30-40MB after the Init SentrySDK

Expected Result

Memory growth is only within 10MB

Actual Result

I try with an "empty" Unity project with Sentry added, After discovering the initial SENTRYSDK, the memory increased by 30-40MB

bitsandfoxes commented 5 months ago

Hey! What do you mean with "memory"? Appsize? Or memory used during runtime?

WeiLingQiang commented 5 months ago

Hey! What do you mean with "memory"? Appsize? Or memory used during runtime?

memory used during runtime, TotalPss Use adb command: adb shell dumpsys meminfo <package_name>

bitsandfoxes commented 5 months ago

Admittedly, 30-40 MB sounds like a lot but there's a whole bunch of things the SDK does. I'd be much more wary about the SDK's behavior over the game's lifecycle. Looking at an empty project's memory profile I'm not sure I see the problem yet. Screenshot 2024-05-15 at 15 42 48 What makes you think there is one?

WeiLingQiang commented 5 months ago

You should check the memory in the Android APK package instead of unity. You can try to use the ADB command to compare the empty project and SentryDemo project adb shell dumpsys meminfo <package_name>

WeiLingQiang commented 5 months ago

企业微信截图_17158253682831 企业微信截图_17158252665697

The above is a screenshot of the ADB command adb shell dumpsys meminfo <package_name>

bitsandfoxes commented 5 months ago

I don't doubt that you are right about the increase. I just tried to illustrate what that memory layout looks like. I'm not convinced that the SDK's memory footprint is an actual issue.

WeiLingQiang commented 5 months ago

Excuse me, is there a way to reduce memory occupation

bitsandfoxes commented 5 months ago

Can you share your configuration of the SDK?

WeiLingQiang commented 5 months ago

SentryOptions.txt

You turn the file to the .asset suffix

bitsandfoxes commented 5 months ago

The only config I can see on your options that I can see have an effect on memory is to reduce the maximum amount of breadcrumbs. But I expect this to be negligible. You can also disable the native Android support and see if that changes the memory consumption in a way that is acceptable to you.

bruno-garcia commented 2 weeks ago

@WeiLingQiang Did you have a chance to try without the native Android support?

We also made a lot of changes since then, have you had a chance to peek at the memory usage again?