Skip to content

Commit

Permalink
Editor: fixed RAM use skyrocketing during sprite reimport from sources
Browse files Browse the repository at this point in the history
It appears that Editor's GC is not cleaning up temporary bitmaps in time, which may lead to temp data taking up all the memory, leading to program's failure.
This is easily seen when reimporting lots of tiles from a huge tileset image, for example.
Should force dispose everything temporary there.
  • Loading branch information
ivan-mogilko committed Nov 24, 2023
1 parent ed9e09e commit f12c8fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Editor/AGS.Editor/Utils/SpriteTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public static IEnumerable<Bitmap> LoadSpritesFromFile(string fileName, int start
// Unfortunately the Bitmap.Clone method will crash later due to
// a .NET bug when it's loaded from a stream. Therefore we need
// to make a fresh copy.
Bitmap oldBmp = loadedBmp;
loadedBmp = Utilities.CreateCopyOfBitmapPreservingColourDepth(loadedBmp);
oldBmp.Dispose();

//Bitmap loadedBmp = new Bitmap(fileName);
if ((System.IO.Path.GetExtension(fileName).ToLower() == ".gif") &&
(loadedBmp.PixelFormat != PixelFormat.Format8bppIndexed))
{
Expand Down

0 comments on commit f12c8fe

Please sign in to comment.