A programming language without access to the underlying system is of little use. Even a “Hello, world!” program requires the OS to output that message. Today we’ll start looking at the system access that the Standard Library provides. We’ll see how to access the file system, so-called “smart” pointers, and check the time using various system clocks.
Posts Tagged allocation
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!
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.
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!
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.
When we use
Allocator.Temp with a collection like
NativeArray, how long does the allocation last? We’ve seen that
Temp allocations are automatically disposed without the need to explicitly call
Dispose, but when does the automatic dispose happen? Today we’ll test to find out!
Unity’s garbage collector is super slow and the bane of our programming life. It’s the reason we can’t use
foreach, have to make pools of objects, and go to great lengths to avoid boxing. It’s also seemingly mandatory, but that’s not quite true. Today’s article shows you a way that you can skip the GC and still allocate memory!