Skip to main content
  1. Quick Notes & Explanations/

2. GC Alloc ve GC Collect

·2 mins· loading · loading ·
Table of Contents

In C# and some Object-Oriented Programming languages, there is the term Garbage Collector. However, in some mid-level programming languages, it is the programmer’s responsibility to remove objects that are no longer needed from memory.

Example: In C++, we destroy an object with the Destructor method.

When a code process (process) starts, an empty space is allocated in memory (memory) for this process. This operation is called “Garbage Allocation”, and the allocated space is technically called the Heap Area. The locations of objects in heap memory are held through references (stacks). Objects created at runtime are cleaned from heap memory when they are no longer needed by the application or when their job is done. The “Garbage Collection” mechanism is used for this operation.

1. What happens if there is not enough space in memory?

The Garbage Collector intervenes and all objects that the application does not need are cleaned from the heap area of memory.

In summary; an object was created with the “new” keyword, the application went to heap memory and realized there was no space. The Garbage Collector intervened and the necessary space was allocated.

2. What is the importance of these statements for optimization in mobile games?

We had mentioned the constraints on mobile devices. We must keep system requirements at the lowest possible level, and accordingly, our memory usage should be optimized.

If memory usage is not optimized, our device will frequently call the Garbage Collector to meet allocation requests. These operations generally have a negative impact on our game running on the main thread because the Garbage Collector process is similar to emptying the recycle bin and unfortunately runs on the main thread in Unity.

Calling GC every frame is a consequence of a high amount of data abuse, and as a result, there will be momentary FPS drops. When hundreds of GameObjects are created simultaneously in the scene, this is the primary reason for our FPS to plummet.

Reply by Email

Related

1. Theory of Constraints & Games
·1 min· loading · loading
Theory of Constraints suggests that every production system has a single constraint that limits the producer from unlimited production, and the goal of the system is to continuously maximize the efficiency of that constraint.
Beat Them All
·1 min· loading · loading
The game offers a strategic experience where players merge houses to create powerful armies, sending them out to defeat their enemies in a visually engaging 3D environment. “Beat Them All 3D” challenges players to think strategically as they merge houses on the battlefield.
Vending Master
·1 min· loading · loading
In this game, you take on the role of a vending master, managing and operating a vending machine to serve customers. The game provides a fun twist on the everyday operation of vending machines by showing the little people working inside to keep things running smoothly.
Bank Idle
·1 min· loading · loading
you step into the role of a bank manager, expanding your bank, managing customers, and protecting your treasury from thieves. The ultimate goal is to grow your bank and become a billionaire.
Trivia Climb
·1 min· loading · loading
The game challenges players to race to the top by answering trivia questions correctly. The more accurate the answers, the higher the jump, with obstacles and other players adding to the excitement.