From c13b938a4bd7e030afd39bd633219aa32f16856e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 8 Sep 2022 13:04:53 +0200 Subject: [PATCH] Free memory when unused, forgotten in my commit d4feb59e --- common/gal/opengl/opengl_gal.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index d39b543a1e..3536d727a5 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -123,8 +123,14 @@ GLuint GL_BITMAP_CACHE::RequestBitmap( const BITMAP_BASE* aBitmap ) { return it->second.id; } + else + { + // Delete the invalid bitmap cache and its data + glDeleteTextures( 1, &it->second.id ); + m_bitmaps.erase( it ); + } - // else if not valid, it will be recreated. + // the cached bitmap is not valid and deleted, it will be recreated. } return cacheBitmap( aBitmap );