fix: memory leaks and heavily optimize the game (#117)

* fixed performance issue on getting texture height for rendering the player model as it loades the player texture on every frame

* updated the lifetime of the texture

* fixed 20 MB memory leak

* delay window display until engine init is done
This commit is contained in:
Joud Kandeel
2026-05-25 22:13:28 +03:00
committed by GitHub
parent 6ed34078fd
commit ef0dad4ffc
3 changed files with 33 additions and 6 deletions
+7 -1
View File
@@ -1256,8 +1256,14 @@ int Textures::getHeight(const wstring& url, int backup)
if (img)
{
MemTexture* _texture = new MemTexture();
_texture->loadedImage = img;
_texture->isLoaded = true;
_texture->id = getTexture(_texture->loadedImage, C4JRender::TEXTURE_FORMAT_RxGyBzAw, MIPMAP);
int h = img->getHeight();
delete img;
//delete img; // commenting this out and inserting the loaded texture to memTextures unordered_map
this->memTextures[url] = _texture;
return h;
}