Select to view content in your preferred language

Out of memory error when downloading mmpk file

811
5
07-10-2023 08:21 PM
DeepamPalaniswami
Occasional Contributor

Hi Team,

I am trying to download a mmpk file to my device and then display it. Map size is 93MB.

When i try to call 

val portalItemData = portalItem.fetchData()

it throws an exception, 

Failed to allocate a 97621424 byte allocation with 25149440 free bytes and 89MB until OOM, target footprint 132745784, growth limit 201326592

If try the sample map download example, its size is 6.4MB. I am able to download it.

Is there any workaround for this?

 

 

0 Kudos
5 Replies
DeepamPalaniswami
Occasional Contributor

I have referred to the sample example in arcGIS to tryout the code.


https://developers.arcgis.com/kotlin/sample-code/display-map-from-mobile-map-package/

0 Kudos
Shubham_Sharma
Esri Contributor

The portal item fetchData property is not ideal for large file downloads as it downloads data to the device's memory. I would recommend using the portal item data endpoint to perform a download and handling the download service as part of your code: 

{portalURL}/sharing/rest/content/items/{itemIdentifier}/data

We plan to release a helper function as part of the Kotlin Maps SDK that would utilize the data endpoint which would be suitable for file downloads of any size mostly for the next 200.x release. 

0 Kudos
DeepamPalaniswami
Occasional Contributor

Hi @Shubham_Sharma ,

 I have tried this URL, just need your confirmation on it.

https://www.arcgis.com/sharing/rest/content/items/<itemId>/data?token=<Auth-Token>

Is that API structured is correct?

0 Kudos
DeepamPalaniswami
Occasional Contributor

Hi Team,

I tried but it throws me a invalid token though its the same auth token I got it when i logged in.

https://www.arcgis.com/sharing/rest/content/items/9f138b1072db4dc793bef409d843567c/data?f=json&token=<auth_token> 

[text={"error":{"code":498,"message":"Invalid token.","details":[]}}]

 

Let me know if i am missing anything

0 Kudos
GuntherHeppner
Esri Contributor

@DeepamPalaniswami 

I'm afraid that if your portal item is secured, it won't be trivial to handle the authentication part (passing the correct token) with your own download implementation. We are going to provide a `ArcGISHttpClient.download()` function as part of our upcoming 200.2.0 release which will handle the authentication part for you. Until then, would you be able to download non-secured (public) portal item data?

0 Kudos