By Aditya Kulkarni From a sales perspective, your new mobile game should always work on most devices people use today. "Most devices" might surprise developers. In January 2015, there were 3.6 billion mobile users worldwide. So it's the developer's job to make the game/app work within the hardware constraints of these devices. Developers need to think more when developing memory-intensive software like games. By writing this article, I hope to help some non-tech-savvy people further understand some of the memory issues they need to consider when working on 2D game projects. 1) Memory leak: Memory leak refers to allocated memory blocks that are not released. Analogy: Let's imagine you are looking for a locker in a room with 3 square lockers.
lockers (from gamecareerguide) 1. John and Danny "need" to store their own gear, and one locker is enough for each of them. So now we have 2 used lockers and 1 unused locker. 2. Now John needs to store his helmet and no longer needs the gear he stored previously. So ideally he should take out the gear and put the helmet in it. But he asks the manager for another locker and wants to put the helmet in the new locker. Logically, all the lockers are full after this. Now John will forget the gear he stored in the first locker. 3. Now Danny needs to store 2 helmets and needs 2 lockers, so he decides to take away his equipment and free up 1 locker. Then he asks the manager for a new locker, but is rejected because all lockers are full. Here, even if John removed the unused equipment from the locker, Danny would not be able to use the extra storage space. 2) Multiple instances of the same texture: A texture will take up width*height*4 (1 byte for red, green, blue and alpha). So a 512x512 image will take up 1.05MB of memory. The same texture will take up 3 times as much memory, 3.15MB. So if we want to use these images as textures we need to prepare 3 times more memory. Analogy: Let's take a square sticker that features your favorite character "buttman" and cannot be used for the first time.
sticker(from gamecareerguide) You need to present this new character to 3 different people. So you can: 1. Get 2 identical stickers, get 3 wooden frames to put the stickers on, and you will hand these wooden frames to the 3 people. 2. Have the 3 people get their own wooden frame and have them stick the stickers on the frame. Example 2 works for us because we can use the same sticker over and over again. This also works in a software program, where everyone can think of buttman at the same time. 3) Unnecessary iterations: It is easier to call a for/while loop in a resource than calling it multiple times. You can handle multiple tasks in one loop. Analogy: You are a spy and need to deliver packages to 3 different remote locations. And you need to collect important secret information from different bosses in these 3 different locations. Since you receive these quests from different bosses, you can: 1. Assign your tasks according to different bosses. For example, you can drive to all three locations and complete the tasks assigned by boss A first, and then drive to the same three locations to complete the tasks assigned by boss B. And vice versa. 2. Assign your tasks according to different places. For example, you can drive to the first place, deliver the package and get information, and then drive to the next place. If you plan your mission like in case 1, you would be a stupid spy because you will need to spend more time and resources to complete the same mission. 4) Keeping unused objects in memory: Only certain objects can be used or appear on the screen at any time. Because we have priority memory space, any extra objects left in memory are consuming resources. Analogy: You need to push a cart from point A to point B. Let's assume that this is an easier task if the cart is unloaded or loaded with the lightest load. But because you like beer, you choose to use the cart to carry a barrel of beer, thus making your task more difficult. So the only solution here is to give up the beer you love. There are definitely more problems than I can cover in one article. As a developer, you should identify these problems as soon as possible and use effective solutions. Overcoming these challenges before releasing the product is the real excitement of game development. Everyone has only 24 hours in a day. For us, people spending this precious time to try out what we create is the biggest motivation for us to develop games. |
<<: Detailed explanation: Objective-C Class Ivar Layout
>>: The most practical picture lazy loading solution
Yunnan's Ailao Mountain unexpectedly became p...
Can small-base accounts and white-label merchants...
On the morning of February 11, 2015, KGI Securiti...
Many CPs are saying that my APP framework and con...
1. The advertising industry’s thoughts and concer...
If you only have one chance to turn things around...
As we all know, the Kennedy Space Center in the U...
Speaking of color striped toothpaste, I believe m...
When it comes to Windows, most people are amazed ...
We must be clear that building a user growth syst...
When it comes to user growth , most people will t...
In recent years, online marketing has gradually b...
During this special Spring Festival holiday, the ...
New media operation, channel selection, and maxim...
Growth hackers are the real source of revenue for...