- Home /
Question by
abrax · Mar 11, 2015 at 07:41 AM ·
performanceprofilerdictionarycollectiongarbage
Accessing value from dict allocates 28 bytes
Hi,
In short, reading and storing the value of a dictionary seems to allocate 28 bytes each time. I was wondering if there was a way around it.
If you're familiar with A* pathfinding, this is the portion that finds the minimum F score amongst the available 'potential future locations' in the open set. The problematic line is:
tempf=infscore[entry];
Because this line is called so often, It's accruing more than 10MB of garbage per frame. Full code of the function is here:
Vector3 minv3(HashSet<Vector3> inopen, Dictionary<Vector3,float> infscore){
float minval = Mathf.Infinity;
float tempf = new float ();
Vector3 retminv3 = new Vector3 ();
foreach(Vector3 entry in inopen){
tempf=infscore[entry];
if (tempf<minval){
minval=tempf;
retminv3=entry;
}
}
return retminv3;
}
Any help would be much appreciated.
Thanks.
Comment
Your answer
Follow this Question
Related Questions
Instantiate/Destroy Garbage Collection advice 1 Answer
How do I get my game to run faster? 4 Answers
Profiler Alpha Mobile 0 Answers
What does Audio CPU Usage mean in the Profiler? 1 Answer
Animator.Update has high CPU usage 2 Answers