Changeset - afd5051b6992
[Not reviewed]
default
0 1 0
Jason Maltzen - 6 years ago 2018-05-03 05:43:57
jason@hiddenachievement.com
Unref and garbage collect after capture to clean up memory and stop crash due to running out of memory.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
UI/CaptureView.cs
Show inline comments
...
 
@@ -248,24 +248,26 @@ namespace DesertPaintLab
 
        {
 
            // Take a screenshot.
 
            int screenWidth, screenHeight;
 
            bool debugScreenshot = false;
 
            bool enableDebugMenu = false;
 
            Gdk.Window rootWindow = Gdk.Global.DefaultRootWindow;
 
            DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
            DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
            DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
            DesertPaintLab.AppSettings.Get("DebugScreenshot", out debugScreenshot);
 
            Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight);
 
            screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
            rootImage.Unref();
 
            System.GC.Collect(); // really, clean up now
 
            //screenBuffer.GetFromDrawable(rootWindow,
 
            //  rootWindow.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
            int stride = screenBuffer.Rowstride;
 
            byte* pixBytes = (byte*)screenBuffer.Pixels;
 
            int redPixelStart = -1;
 

	
 
            StreamWriter log = null;
 
            if (enableDebugMenu)
 
            {
 
                string logfile = FileUtils.FindNumberedFile("DesertPaintLab_Capture", "log", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
 
                log = new StreamWriter(logfile);
 
                ReactionRecorder.Instance.Log = log;
0 comments (0 inline, 0 general)