Memory Flashcards

1
Q

Why is garbage collection bad in VR?

A

The negative repercussion of having garbage is the hit to framerate. Loss of frames result in you dipping below the required 90 frames for pc, or 60 frames for mobile.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

_____ is used to store value types in the garbage(collected heap). ______ is an implicit conversion of a value type to the type object or any interface type implemented by this value type. ______ a value type allocates an object instance on the heap and copies the value into the new object.

A

Boxing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

_______ is an explicit conversion from the type object to a value type or from an interface type to a value type that implements the interface. ______ consists of checking the object instance to make sure that it is a boxed value of the given value type. Also for copying the value from the instance into the value-type variable.

A

Unboxing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

With _____ ______ when an object, string or array is created, the memory required to store it is allocated from a central pool called the heap. Then the item is no longer in use, the memory it once occupied can be reclaimed and used for something else. Automatic _____ ______ requires less coding effort than explicit allocation/release and greatly reduces the potential for memory leakage(the situation where memory is allocated but never subsequently released).

A

memory management

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The memory manager keeps track of areas in the heap that it knows to be unused. When a new block of memory is requested(say when an object is instantiated), the manager chooses an unused area from which to allocate the block and then removes the allocated memory from the known unused space. Subsequent requests are handled the same way until there is no free area large enough to allocate the required block size. It is highly unlikely at this point that all the memory allocated from the heap is still in use. A reference item on the heap can only be accessed as long as there are still reference variables that can locate it. If all references to a memory block are gone(ie, the reference variables have been reassigned or they are local variables that are now out of scope) then the memory it occupies can safely be reallocated.

A

allocations in memory management

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain unity’s garbage collection(Boehm GC)

A

Unity uses the Boehm–Demers–Weiser garbage collector. A stop-the-world-garbage collector. Whenever unity needs to perform garbage collection, it stops running your program code and only resumes normal execution when the garbage collector has finished all its work. This interruption can cause delays in the execution of your game that last anywhere from less than one millisecond to hundreds of milliseconds. This is depending on how much memory the garbage collector needs to process and on the platform the game is running on. For real-time applications like games, this can become quite a big issue, because you can’t sustain the consistent frame rate that smooth animation requires when the garbage collector suspends a game’s execution. These interruptions are also known as GC spikes, because they show as spikes in the profiler frame time graph.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the key differences between C# and unity’s GC

A

Unity’s GC is non generational and non compacting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why does memory fragmentation happen in unity?

A

Unity’s GC is non compacting, leaving holes in the heap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly