Archive for category Unity

Function Pointers in Burst

Tags: , ,

Unity 2019.3 and Burst 1.2 bring us support for function pointers! Behind the scenes, these power everyday C# functionality like virtual and abstract functions, delegates, and interfaces. Today we’ll look at how to use them and what Burst compiles them to.

Read the rest of this article »

1 Comment

How Many Temp Allocators Are there?

Tags: , , , ,

Last time we saw that jobs apparently have their own Temp allocator. Still, it was unclear how many of these allocators there are. One per job job? One per thread? Just one? Today we’ll run an experiment to find the answer!

Read the rest of this article »

No Comments

Job-Safe APIs in Unity 2019.3

Tags: , ,

Today’s article continues the series by finding all the job-safe APIs in the Unity engine as of 2019.3. We’ll compare against 2019.1 to see what’s new!

Read the rest of this article »

No Comments

Temp Memory Reuse

Tags: , , , ,

Temp memory is backed by a fixed size block that’s cleared by Unity every frame. Allocations on subsequent frames return pointers to this same block. The allocated memory therefore isn’t unique. How much of a problem is this? Today we’ll do some experiments to find out!

Read the rest of this article »

No Comments

Allocating Memory Within a Job: Part 2

Tags: , , , ,

Last week’s article came to the conclusion that allocating Temp memory from within a job was safe. This week we’ll look into that a little deeper to find out that it might not be as safe as it looks!

Read the rest of this article »

No Comments

Allocating Memory Within a Job

Tags: , , , ,

What do you do when a job you’re writing needs to allocate memory? You could allocate it outside of the job and pass it in, but that presents several problems. You can also allocate memory from within a job. Today we’ll look into how that works and some limitations that come along with it.

Read the rest of this article »

2 Comments

Are Temp Allocations Always Fast?

Tags: , ,

We’ve seen that Temp allocations are the fastest kind of allocations, but is this always the case? When the fixed-size block of memory they draw from runs out, are the overflow allocations just as fast? Today we’ll test to find out!

Read the rest of this article »

No Comments

Deallocating Temp Memory: Part 3

Tags: , , ,

Continuing the series, today we look specifically at “overflow” allocations in the Temp allocator. We’ve seen that there’s no need to explicitly deallocate Temp memory because it all gets cleared every frame, but do we need to deallocate “overflow” allocations that didn’t fit inside the block of automatically-cleared memory? Today we’ll find out!

Read the rest of this article »

No Comments

Deallocating Temp Memory: Part 2

Last week we dove into the code that executes when we deallocate Allocator.Temp memory to try to find out what happens. We ended up at a dead-end and were only able to draw conclusions about what doesn’t happen when we deallocate. Today we’ll try another approach to see if we gain gain more insight into the Temp allocator.

Read the rest of this article »

2 Comments

What Does Deallocating Temp Memory Do?

Tags: , , ,

Last week we learned a lot about Allocator.Temp, but we left some questions open. One of them was what happens when we explicitly deallocate Temp memory. We know we don’t need to and that it’ll be deallocated at the end of the frame, but what happens when we explicitly deallocate it? Today we’ll dive in and try to find out.

Read the rest of this article »

4 Comments