Questions tagged [memory-efficiency]
A way of organizing and storing information so that it occupies as small an amount of memory as possible while still retaining its full usefulness.
159 questions
1
vote
0
answers
52
views
Reserved Memory Keep Increasing When Loading the Same GameObject Using Unity Addressables
I'm trying to learn how to use Addressables in Unity to improve memory usage, but there's something I don't understand.
I use ...
0
votes
1
answer
135
views
What is the preferred memory to store game object into, Stack memory or Heap memory
In the context of game dev, what is the preferred memory to use to store structs like Entities or MapData which are large in size and have lifetimes lasting the entire game run-time.
For example here ...
0
votes
1
answer
151
views
How to efficiently construct model matrices in a vertex shader from a small amount of data, for instanced rendering of many moving 3d game characters
I am trying to efficiently render many 3d game characters: many instances of the same 3d model which can change their positions and z rotations each frame. For reference I'm using OpenGL but this ...
0
votes
0
answers
61
views
What are some different ways that tiles are stored in a game during runtime
I am making a 2d rpg game that uses tiles to store the terrain data. Also the map is procedural generated infinite world type.
I saw an approach called clipmaps to ...
0
votes
0
answers
128
views
Unable to determine cause of memory leak in Unity when using Addressables. Can anyone give suggestions on what the cause might be?
I'm creating a simple bullet hell game for Android and I ran into an issue when diagnosing my game using the Memory Profiler where memory usage was increasing after each play-through. I had calls to ...
3
votes
2
answers
194
views
How to make a digger-like procedurally generated maze that can be queried at coordinates without having to generate?
I would like to procedurally-generate ant farm-style layouts on a grid: long horizontal spaces connected by short vertical spaces. Also similar to cave systems formed by water erosion.
Every tile in ...
1
vote
1
answer
267
views
I am testing the flyweight pattern on thousands of GameObjects but its not helping save memory. What am I doing wrong here?
I am trying to understand the flyweight pattern better by trying to optimize memory usage by spawning 10000 copies of an enemy GameObject that I have which has an Animator component, SpriteRenderer ...
0
votes
0
answers
56
views
Can I extract/bake the collisions generated by a tilemap collider?
Given a tilemap, with a tilemap collider, is it possible to extract/bake the current collision(s) onto a separate gameobject independent from the tilemap/tilemap collider?
My 2D game streams a large ...
2
votes
1
answer
344
views
Padding in a vec3f array in WebGPU memory layout
I'm trying to write a WGSL structs parser (sort of webgpu-utils thing). In order to better understand the memory layout, I'm using wgsl offset computer as a helper.
Having the next struct:
...
1
vote
0
answers
133
views
Can you append values to an appendbuffer and then immediately read from that same buffer?
I am looking to achieve the following: I have a compute shader that receives a Texture2D as input, where a small percentage of the pixels in the texture are white. ...
4
votes
2
answers
3k
views
How does Godot 4 copy vectors?
I'm an old coder, but a newbie to Godot. I'm using version 4.
I got some unexpected (to me) behavior when I tried this code:
...
16
votes
1
answer
6k
views
Blank 2.2 KB sized PNG costs 2.1 MB in Unity? What does this represent? What to do?
I am starting to work on optimization for my app. I need to understand the information Unity displays about file sizes. For example, just to prove a point, here is a 2.2 KB completely blank PNG which ...
0
votes
1
answer
941
views
what is more memory intensive in Unity: 100 GameObjects with PaticleSystems, or 100 GameObjects spawning other GOs
I am making a bullet hell game. Say there are 100 bullets on the screen, and each bullet has a trail effect. Is it more performant to give each GameObject a ParticleSystem, or for each GameObject, ...
0
votes
2
answers
787
views
If I create a prefab out of an object on scene will my game take more memory in Unity?
If I create a prefab out of an object on scene will my game take more memory in Unity?
I have 30 enemies on my scene. I created a prefab for every one of them. I am going to use each of the created ...
1
vote
1
answer
9k
views
Issue with Texture2D memory leak in Unity
I have a simple method that converts RenderTexture data into Texture2D
...
0
votes
0
answers
101
views
Rendering efficiency for retro 2d grid chipset games. Draw by texture, or by row col?
This was the closest question on found here: Help with a Fast 2D Grid-Based world rendering technique
I'm doing a basic 2d grid where each box is filled with a texture pulled from a chipset. I'm ...
2
votes
1
answer
863
views
OpenGL: What to do after running glBufferData?
I am interested in understanding a bit more behind how OpenGL does its memory management and what are some good practices before I start heavily coding and back myself into a corner.
The real question ...
0
votes
0
answers
118
views
Should I preload interstitial ads when my game starts?
I just recently added interstitial ads to my game. I loaded my interstitial ads when the main game actually starts so it wouldn't take long to load after the user exits to the menu, but on profiling ...
-1
votes
2
answers
115
views
How to load 3D modells when they are necessary
I'm working on a 3D game engine, currently I load ALL of my 3D modells into the memory when my game starts, but obviusly there will be hundreds of 3D modells, so somehow I should unload them when they ...
1
vote
0
answers
65
views
How can I remove sprites when they are outside viewport, but then add them again if I return to their location to save memory
I'm creating an open-world RPG like Neverwinter nights. But I’m worried about memory and am afraid if I just populate a huge world with physics based sprite nodes, I won't have any memory for anything ...
4
votes
1
answer
6k
views
Game Engine Memory Allocator
I'm a bit confused on how to implement an allocator for my game engine. I'm currently trying to implement PhysX for the physics in my game and it requires an implementation of an abstract allocator ...
0
votes
0
answers
97
views
Game graphics taking too much memory of 0.5 GB
I am developing a simple 2D game. I have multiple sprites. Each sprite has around 80 png/frames of 265* 256. I used LibGdx's Texture packer to package the atlas. Am enabling mimap using following code ...
6
votes
1
answer
1k
views
How do open world game engines allocate memory?
My troubles
I've been trying to create a game engine but since I am not well experienced in C++ I am having trouble deciding on how to load new scenes efficiently level by level or just an open world.
...
-1
votes
1
answer
201
views
Quickly Running Out Of Memory
Over the past months I have been developing an application using Vulkan. Recently I have implemented loading 3d models from .fbx files and their associated .png textures. At this point there appears ...
8
votes
1
answer
2k
views
Use floats or doubles when writing mobile games
I know for shaders, floats should be used because they are the optimal choice for performance. Doubles are slow and use more memory which isn't ideal for shaders. While floats are less accurate and ...
1
vote
1
answer
98
views
Memory tracker allocates while outputting results
I've written a memory tracker for use in my game engine. I based it on this slide in a talk by Nicolai Josuttis.
One problem I'm having is that, during reporting, the implicit string conversion and ...
1
vote
0
answers
337
views
How to render decoded video that is on GPU memory without copying to CPU
I'm reading this example of ffmpeg hardware decoding: https://github.com/FFmpeg/FFmpeg/blob/release/4.2/doc/examples/hw_decode.c
At line 109 it does this:
...
0
votes
1
answer
555
views
frame rate drop in html5 game
i have Incorporated gravity mechanics and collision mechanics to my game. the game works fine for some period of time after that i am getting significant amount of frame rate drop.i am doing some ...
1
vote
2
answers
1k
views
Unreasonably large memory use with high-res screenshot script
I'm using this piece of code to save renders and I'm saving renders in every frame inside Update().
Code:
...
0
votes
0
answers
55
views
How to find the source of a memory leak in a Blockchain + Node.js game
We have been working in a Node.js game, part of a game network, which seems to be working slower and slower as you keep it open, as well as it seems to increase the RAM and CPU usage over time.
We ...
1
vote
0
answers
98
views
No-duplicate collection without iterator allocation [closed]
Problem
I need a collection with non-duplicate values minimising memory allocation during access operations. I am prepared to compromise with a slight decrease of performance to make up for the ...
0
votes
2
answers
304
views
Any advantage of having chunks with sizes by the power of two?
With my past experience of having my little game lag because of the size of the world, I have decided that in whatever next project I might choose to create, I will split said world into chunks. Now ...
1
vote
1
answer
2k
views
Avoiding GC Allocation in Unity UNet API
I'm trying to profile the game using Unity Profiler, I can see in the Hierarchy tab that there's an 18.3 KB correlated to ...
1
vote
1
answer
1k
views
Unity - SpriteAtlas memory consumption
I'm in the process of optimizing my application memory consumption.
To do so, I'm using Unity profiler while connecting to an Android device, which runs a development build of the application.
The ...
3
votes
1
answer
3k
views
Unity3d - Do I need to destroy gameobject AND script?
From proper leak protection do I need to delete both of these or will getting rid of one take care of both?
Currently I am destroying the script AND the gameobject
...
1
vote
2
answers
929
views
How can I store my 2D map in JAVA?
I'm working on a 2d adventure game where the player can explore a random generated map. It's working perfectly if I set it to be about 3000x1000 blocks (my array is 3000x1000x2), but this is TOO SMALL....
1
vote
1
answer
630
views
Avoiding Out-Of-Ram Crashes in unity [closed]
My Players experience crashes on older computers when they enter a scene with a lots of 3d models.
Is there anything I can do to avoid this, except deleting those models from the scene?
0
votes
1
answer
869
views
How do open world games handle efficiently enemy respawn?
I'm currently working on a 2D open world game loaded in chunks, initially I thought It would be sufficient to spawn entities randomly in a specific "radius" close to the player, and periodically ...
1
vote
1
answer
3k
views
Memory is not getting freed on Destroy()
Manager script(simple script attached to an empty GameObject on scene) on Start() instantiates 1000 default cubes with rigidbody component added and gravity check ticked.
...
1
vote
0
answers
51
views
string[] preallocation to prevent using ToString() and save memory
I have some levels, with enemy waves and two Text components for:
Enemies killed, like: "13/57"
Waves passed, like: "68"
On each enemy kill/new wave, I make a <...
3
votes
0
answers
221
views
MeshMemory causing constant spikes
I have a ready-to-launch application, cleaning everything right now. I have these strange spikes on Mesh Memory.
The best part of it is that this view below is ...
-1
votes
1
answer
118
views
Static variable pre-declaration & memory heap expansion in Unity
When I profile my apps, I make sure that the code like this one:
private void Update(){
int count = GetEnemyCount();
}
get's converted to this one:
...
1
vote
1
answer
1k
views
How can I make a custom memory allocation for classes with virtual methods? [closed]
I want to create a custom allocator that stores objects to the heap sequentially. The allocator itself is very simple. It just allocates a big chunk of memory and moves an offset as ...
3
votes
2
answers
733
views
Is single/double frame allocator suitable only for POD datas?
Let´s say I have a single frame stack allocator, so I´m using it for allocating memories for my temporary data.
...
30
votes
2
answers
6k
views
Is A* efficient even when the obstacles are moving?
I'm just starting to learn about path-finding and have been looking into the A* algorithm and my main concern is that it all of the examples I have seen show static obstacles that it computes around.
...
0
votes
1
answer
3k
views
Unity mobile game generates too much cache
I have built a game I have been working on for Android (Unity). It's a simple game: air hockey. It weights 21mb with all the assets and scripts.
After playing for a bit I have noticed that cache of ...
24
votes
1
answer
6k
views
Why should I always consider creating and using object pools instead of instantiating the new object on the fly?
I have read about this pattern several times (from a best-practices perspective):
Memory Allocation: Instead of instantiating the new object on the fly, always consider creating and using object ...
0
votes
1
answer
2k
views
DirectX11 bind all textures at once?
If my game will use say 100mb of raw memory for textures, would it be a good idea to put all of them in srv array, bind once and leave it for the rest of the program so that I won't have to bind them ...
0
votes
1
answer
540
views
What is more efficient in Unity recorded animation or Slerp/Lerp?
What is more efficient in Unity recorded animation or Slerp/Lerp? What will be faster?
It is obvious that the animation will take a lot more space.
1
vote
0
answers
135
views
When should I use auto-managed buffers in LWJGL 3?
LWJGL3 has two methods of creating buffers that I know of: Auto-managed buffers that clean up the buffers automatically using the MemoryStack class, and manually managed buffers that must be manually ...