Way to reduce garbage allocation when setting location?

332
2
02-13-2023 12:52 PM
ERS_Collins
New Contributor

Hi there, I'm curious if there is a more efficient way to set the location of an object on the ArcGISMap at runtime. The way I have seen requires the creation of a new ArcGISPoint and then setting the location component's Position to this new ArcGISPoint object.

For my game, I'm having to create a point every frame in Update since my lat/lon/alt data is being streamed in from an external source. This data moves the player's vehicle around the world. Is there is a better, more efficient alternative I can use in this scenario for setting position? Is this the only way to change a position using Lat/Lon/Alt? Since I am having to do this every frame, I am creating a lot of garbage for the garbage collector, and this is pretty slow.

I have looked into setting the X/Y/Z on the location component's Position (an ArcGISPoint), but this is not possible as those properties are get-only. For this same reason it is not possible to cache an ArcGISPoint, adjust its X/Y/Z, and set the location component equal to this cached point.

 

Thanks in advance!

ERS

2 Replies
JacobDunbar
New Contributor

@ERS_Collins If you made any progress with this since a year ago I'd appreciate any findings you're willing to share!

We're working with streamed lat/lon data for 400+ entities which is making this garbage collection issue cause significant spikes every 2-3 seconds. I'd love to know if there's a more efficient way we could update the locations of so many objects so frequently. We're using a local map and a fixed WKID of 4326 (WGS84), so in theory there should be a way to calculate a universe position to set an HPTransform directly and bypass using ArcGISLocationComponent/ArcGISPoint entirely.

The big garbage collection spikes happen in ArcGISLocationComponent's LateUpdate method.

Any help is appreciated, thank you!

arcgis_location_profiling.png

 

 

0 Kudos
ERS_Collins
New Contributor

Hi, unfortunately no. I wasn't able to figure out a solution for this and actually ended up using a different plugin that enabled me to store maps locally since my end use case was in an offline environment. If you do solve this, please let me know as I'm still interested in a solution when I eventually can use Esri's plugin again

0 Kudos