Select to view content in your preferred language

Memory Leak when update ArcGISURLSession

247
6
3 weeks ago
ByronAndres
Occasional Contributor

Hi,

We enable on our app the use of cache for the maps views, so we are using the following code to activate this option:

        ArcGISEnvironment.urlSession = ArcGISURLSession {
            let defaultConfig = URLSessionConfiguration.default
            defaultConfig.requestCachePolicy = .returnCacheDataElseLoad
            return defaultConfig
        }

While analyzing the app in Profile mode on Xcode, we noticed that this configuration causes a memory leak each time the map is loaded. Below is the error displayed in the Xcode Profile:

Screenshot 2025-01-20 at 11.54.44 AM.pngScreenshot 2025-01-20 at 11.52.20 AM.png

We would like to confirm with you whether this is the correct way to set up the cache configuration. Additionally, do you have any insights into what might be causing the issue with the map when it loads for the first time?

Thanks,

Tags (4)
6 Replies
RyanOlson1
Esri Contributor

we noticed that this configuration causes a memory leak each time the map is loaded.

Does this occur more than once per run of your app? If so, how much memory is leaked in a typical run of the app?

0 Kudos
ByronAndres
Occasional Contributor

Hi @RyanOlson1 This occurs each time a screen with the map is loaded, which means it can happen multiple times during a single run.

0 Kudos
RyanOlson1
Esri Contributor

Why do you need to set the URLSession every time a map is loaded?

0 Kudos
ByronAndres
Occasional Contributor

Apologies for not explaining the issue clearly. We only set up the URLSession once, but we observe a memory leak every time we open the map.

0 Kudos
Destiny_Hochhalter
Esri Contributor

Hi @ByronAndres,

Can you include a minimum reproducible example via a code snippet or project that sets the ArcGISEnvironment.urlSession configuration and loads a map? I am able to reproduce the memory leak.

0 Kudos
ByronAndres
Occasional Contributor

Sure, I'll send you a direct message with the code where we reproduce this memory leak.

Thanks,

0 Kudos