none
C# out of memory Exception 'System.OutOfMemoryException' and System.StackOverflowException' in System.Drawing.dll RRS feed

  • Question

  • I'm Developing a large software with settings in c#. Everything was working fine but suddenly when I hit play button after 30-60 seconds it stops and gives me out of memory Exception System.Drawing.dll. any idea to solve this problem?

     I have the setting form [where the problem is from], Splash screen, MainForm:

    when I start the Main form in the splash screen, the debug stops and shows me the error in the setting who is not started. In the main form where I'm changing images reports me an <g class="gr_ gr_17 gr-alert gr_gramm gr_hide gr_inline_cards gr_run_anim Grammar" data-gr-id="17" id="17">Error</g> An unhandled exception of type 'System.StackOverflowException' occurred in System.Drawing.dll When declaring Image img1_w_path = Properties.Resources.convert_g,

    Full source code Settings.designer :

    nversion = new System.Windows.Forms.Label();
            this.dpdSimulConversion = new Bunifu.Framework.UI.BunifuDropdown();
            this.imgbtnSave = new Bunifu.Framework.UI.BunifuImageButton();
            this.btnDevConsole = new Bunifu.Framework.UI.BunifuThinButton2();
            this.btnResetWarning = new Bunifu.Framework.UI.BunifuThinButton2();
            ((System.ComponentModel.ISupportInitialize)(this.imgbtnSave)).BeginInit();
            this.SuspendLayout();
            // 
            // ckbPlaySound
            // 
            this.ckbPlaySound.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.ckbPlaySound.ChechedOffColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.ckbPlaySound.Checked = true;
            this.ckbPlaySound.CheckedOnColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.ckbPlaySound.ForeColor = System.Drawing.Color.White;
            this.ckbPlaySound.Location = new System.Drawing.Point(31, 195);
            this.ckbPlaySound.Name = "ckbPlaySound";
            this.ckbPlaySound.Size = new System.Drawing.Size(20, 20);
            this.ckbPlaySound.TabIndex = 0;
            // 
            // text_Language
            // 
            this.text_Language.AutoSize = true;
            this.text_Language.BackColor = System.Drawing.Color.Transparent;
            this.text_Language.Font = new System.Drawing.Font("Century Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.text_Language.ForeColor = System.Drawing.Color.White;
            this.text_Language.Location = new System.Drawing.Point(34, 26);
            this.text_Language.Name = "text_Language";
            this.text_Language.Size = new System.Drawing.Size(86, 17);
            this.text_Language.TabIndex = 6;
            this.text_Language.Text = "Language : ";
            // 
            // text_CheckForUpdate
            // 
            this.text_CheckForUpdate.AutoSize = true;
            this.text_CheckForUpdate.BackColor = System.Drawing.Color.Transparent;
            this.text_CheckForUpdate.Font = new System.Drawing.Font("Century Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.text_CheckForUpdate.ForeColor = System.Drawing.Color.White;
            this.text_CheckForUpdate.Location = new System.Drawing.Point(34, 67);
            this.text_CheckForUpdate.Name = "text_CheckForUpdate";
            this.text_CheckForUpdate.Size = new System.Drawing.Size(135, 17);
            this.text_CheckForUpdate.TabIndex = 6;
            this.text_CheckForUpdate.Text = "Check for update : ";
            // 
            // text_ResetDialogs
            // 
            this.text_ResetDialogs.AutoSize = true;
            this.text_ResetDialogs.BackColor = System.Drawing.Color.Transparent;
            this.text_ResetDialogs.Font = new System.Drawing.Font("Century Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.text_ResetDialogs.ForeColor = System.Drawing.Color.White;
            this.text_ResetDialogs.Location = new System.Drawing.Point(34, 128);
            this.text_ResetDialogs.Name = "text_ResetDialogs";
            this.text_ResetDialogs.Size = new System.Drawing.Size(186, 17);
            this.text_ResetDialogs.TabIndex = 6;
            this.text_ResetDialogs.Text = "Reset all dialogs warnings : ";
            // 
            // text_PlaySoundVideoCompleted
            // 
            this.text_PlaySoundVideoCompleted.AutoSize = true;
            this.text_PlaySoundVideoCompleted.BackColor = System.Drawing.Color.Transparent;
            this.text_PlaySoundVideoCompleted.Font = new System.Drawing.Font("Century Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.text_PlaySoundVideoCompleted.ForeColor = System.Drawing.Color.White;
            this.text_PlaySoundVideoCompleted.Location = new System.Drawing.Point(57, 198);
            this.text_PlaySoundVideoCompleted.Name = "text_PlaySoundVideoCompleted";
            this.text_PlaySoundVideoCompleted.Size = new System.Drawing.Size(181, 17);
            this.text_PlaySoundVideoCompleted.TabIndex = 6;
            this.text_PlaySoundVideoCompleted.Text = "Play Sound on task finished";
            // 
            // dpdLanguage
            // 
            this.dpdLanguage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.dpdLanguage.BorderRadius = 3;
            this.dpdLanguage.Cursor = System.Windows.Forms.Cursors.Hand;
            this.dpdLanguage.DisabledColor = System.Drawing.Color.Gray;
            this.dpdLanguage.Font = new System.Drawing.Font("Century Gothic", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dpdLanguage.ForeColor = System.Drawing.Color.White;
            this.dpdLanguage.Items = new string[] {
        "Deutsch ",
        "English",
        "Español",
        "Français",
        "Português",
        "中文",
        "日本語",
        "عربى",
        "हिंदी"};
            this.dpdLanguage.Location = new System.Drawing.Point(399, 26);
            this.dpdLanguage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.dpdLanguage.Name = "dpdLanguage";
            this.dpdLanguage.NomalColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.dpdLanguage.onHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.dpdLanguage.selectedIndex = 1;
            this.dpdLanguage.Size = new System.Drawing.Size(142, 24);
            this.dpdLanguage.TabIndex = 7;
            this.dpdLanguage.onItemSelected += new System.EventHandler(this.dpdLanguage_onItemSelected);
            // 
            // dpdUpdateFrequency
            // 
            this.dpdUpdateFrequency.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.dpdUpdateFrequency.BorderRadius = 3;
            this.dpdUpdateFrequency.DisabledColor = System.Drawing.Color.Gray;
            this.dpdUpdateFrequency.Font = new System.Drawing.Font("Century Gothic", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dpdUpdateFrequency.ForeColor = System.Drawing.Color.White;
            this.dpdUpdateFrequency.Items = new string[] {
        "Never",
        "Every Day",
        "Every Month",
        "Every Week"};
            this.dpdUpdateFrequency.Location = new System.Drawing.Point(399, 60);
            this.dpdUpdateFrequency.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.dpdUpdateFrequency.Name = "dpdUpdateFrequency";
            this.dpdUpdateFrequency.NomalColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.dpdUpdateFrequency.onHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.dpdUpdateFrequency.selectedIndex = 1;
            this.dpdUpdateFrequency.Size = new System.Drawing.Size(142, 24);
            this.dpdUpdateFrequency.TabIndex = 7;
            // 
            // ckbPlayConverted
            // 
            this.ckbPlayConverted.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.ckbPlayConverted.ChechedOffColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.ckbPlayConverted.Checked = true;
            this.ckbPlayConverted.CheckedOnColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.ckbPlayConverted.ForeColor = System.Drawing.Color.White;
            this.ckbPlayConverted.Location = new System.Drawing.Point(31, 165);
            this.ckbPlayConverted.Name = "ckbPlayConverted";
            this.ckbPlayConverted.Size = new System.Drawing.Size(20, 20);
            this.ckbPlayConverted.TabIndex = 0;
            // 
            // text_PlayConvertedVid
            // 
            this.text_PlayConvertedVid.AutoSize = true;
            this.text_PlayConvertedVid.BackColor = System.Drawing.Color.Transparent;
            this.text_PlayConvertedVid.Font = new System.Drawing.Font("Century Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.text_PlayConvertedVid.ForeColor = System.Drawing.Color.White;
            this.text_PlayConvertedVid.Location = new System.Drawing.Point(57, 168);
            this.text_PlayConvertedVid.Name = "text_PlayConvertedVid";
            this.text_PlayConvertedVid.Size = new System.Drawing.Size(253, 17);
            this.text_PlayConvertedVid.TabIndex = 6;
            this.text_PlayConvertedVid.Text = "Play Converted Video on task finished";
            // 
            // text_Num_video_conversion
            // 
            this.text_Num_video_conversion.AutoSize = true;
            this.text_Num_video_conversion.BackColor = System.Drawing.Color.Transparent;
            this.text_Num_video_conversion.Font = new System.Drawing.Font("Century Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.text_Num_video_conversion.ForeColor = System.Drawing.Color.White;
            this.text_Num_video_conversion.Location = new System.Drawing.Point(34, 97);
            this.text_Num_video_conversion.Name = "text_Num_video_conversion";
            this.text_Num_video_conversion.Size = new System.Drawing.Size(315, 17);
            this.text_Num_video_conversion.TabIndex = 6;
            this.text_Num_video_conversion.Text = "The number of simultaneous video conversion : ";
            // 
            // dpdSimulConversion
            // 
            this.dpdSimulConversion.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.dpdSimulConversion.BorderRadius = 3;
            this.dpdSimulConversion.DisabledColor = System.Drawing.Color.Gray;
            this.dpdSimulConversion.Font = new System.Drawing.Font("Century Gothic", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dpdSimulConversion.ForeColor = System.Drawing.Color.White;
            this.dpdSimulConversion.Items = new string[] {
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "10"};
            this.dpdSimulConversion.Location = new System.Drawing.Point(481, 97);
            this.dpdSimulConversion.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.dpdSimulConversion.Name = "dpdSimulConversion";
            this.dpdSimulConversion.NomalColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(43)))), ((int)(((byte)(44)))));
            this.dpdSimulConversion.onHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.dpdSimulConversion.selectedIndex = 0;
            this.dpdSimulConversion.Size = new System.Drawing.Size(60, 24);
            this.dpdSimulConversion.TabIndex = 7;
            // 
            // imgbtnSave
            // 
            this.imgbtnSave.BackColor = System.Drawing.Color.Transparent;
            this.imgbtnSave.Image = global::MySoft_Studio_Soft_UI.Properties.Resources.save_g;
            this.imgbtnSave.ImageActive = null;
            this.imgbtnSave.Location = new System.Drawing.Point(534, 343);
            this.imgbtnSave.Name = "imgbtnSave";
            this.imgbtnSave.Size = new System.Drawing.Size(30, 37);
            this.imgbtnSave.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.imgbtnSave.TabIndex = 12;
            this.imgbtnSave.TabStop = false;
            this.imgbtnSave.Zoom = 10;
            this.imgbtnSave.Click += new System.EventHandler(this.imgbtnSave_Click);
            // 
            // btnDevConsole
            // 
            this.btnDevConsole.ActiveBorderThickness = 1;
            this.btnDevConsole.ActiveCornerRadius = 10;
            this.btnDevConsole.ActiveFillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.btnDevConsole.ActiveForecolor = System.Drawing.Color.White;
            this.btnDevConsole.ActiveLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.btnDevConsole.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(51)))), ((int)(((byte)(52)))));
            this.btnDevConsole.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnDevConsole.BackgroundImage")));
            this.btnDevConsole.ButtonText = "Run Dev Console";
            this.btnDevConsole.Cursor = System.Windows.Forms.Cursors.Hand;
            this.btnDevConsole.Font = new System.Drawing.Font("Century Gothic", 10F);
            this.btnDevConsole.ForeColor = System.Drawing.Color.White;
            this.btnDevConsole.IdleBorderThickness = 1;
            this.btnDevConsole.IdleCornerRadius = 10;
            this.btnDevConsole.IdleFillColor = System.Drawing.Color.Transparent;
            this.btnDevConsole.IdleForecolor = System.Drawing.Color.White;
            this.btnDevConsole.IdleLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.btnDevConsole.Location = new System.Drawing.Point(4, 343);
            this.btnDevConsole.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.btnDevConsole.Name = "btnDevConsole";
            this.btnDevConsole.Size = new System.Drawing.Size(134, 36);
            this.btnDevConsole.TabIndex = 11;
            this.btnDevConsole.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.btnDevConsole.Click += new System.EventHandler(this.btnDevConsole_Click);
            // 
            // btnResetWarning
            // 
            this.btnResetWarning.ActiveBorderThickness = 1;
            this.btnResetWarning.ActiveCornerRadius = 10;
            this.btnResetWarning.ActiveFillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.btnResetWarning.ActiveForecolor = System.Drawing.Color.White;
            this.btnResetWarning.ActiveLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.btnResetWarning.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(51)))), ((int)(((byte)(52)))));
            this.btnResetWarning.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnResetWarning.BackgroundImage")));
            this.btnResetWarning.ButtonText = "Reset all Warning";
            this.btnResetWarning.Cursor = System.Windows.Forms.Cursors.Hand;
            this.btnResetWarning.Font = new System.Drawing.Font("Century Gothic", 10F);
            this.btnResetWarning.ForeColor = System.Drawing.Color.White;
            this.btnResetWarning.IdleBorderThickness = 1;
            this.btnResetWarning.IdleCornerRadius = 10;
            this.btnResetWarning.IdleFillColor = System.Drawing.Color.Transparent;
            this.btnResetWarning.IdleForecolor = System.Drawing.Color.White;
            this.btnResetWarning.IdleLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(187)))), ((int)(((byte)(125)))));
            this.btnResetWarning.Location = new System.Drawing.Point(399, 129);
            this.btnResetWarning.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.btnResetWarning.Name = "btnResetWarning";
            this.btnResetWarning.Size = new System.Drawing.Size(142, 36);
            this.btnResetWarning.TabIndex = 11;
            this.btnResetWarning.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // ucSetting_Gerneral
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(55)))), ((int)(((byte)(51)))), ((int)(((byte)(52)))));
            this.Controls.Add(this.imgbtnSave);
            this.Controls.Add(this.btnDevConsole);
            this.Controls.Add(this.btnResetWarning);
            this.Controls.Add(this.dpdSimulConversion);
            this.Controls.Add(this.dpdUpdateFrequency);
            this.Controls.Add(this.dpdLanguage);
            this.Controls.Add(this.text_Num_video_conversion);
            this.Controls.Add(this.text_ResetDialogs);
            this.Controls.Add(this.text_CheckForUpdate);
            this.Controls.Add(this.text_PlayConvertedVid);
            this.Controls.Add(this.text_PlaySoundVideoCompleted);
            this.Controls.Add(this.text_Language);
            this.Controls.Add(this.ckbPlayConverted);
            this.Controls.Add(this.ckbPlaySound);
            this.Name = "ucSetting_Gerneral";
            this.Size = new System.Drawing.Size(567, 383);
            this.Load += new System.EventHandler(this.ucSetting_Gerneral_Load);
            ((System.ComponentModel.ISupportInitialize)(this.imgbtnSave)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
    
        }
    
        #endregion
    
        private Bunifu.Framework.UI.BunifuCheckbox ckbPlaySound;
        private System.Windows.Forms.Label text_Language;
        private System.Windows.Forms.Label text_CheckForUpdate;
        private System.Windows.Forms.Label text_ResetDialogs;
        private System.Windows.Forms.Label text_PlaySoundVideoCompleted;
        private Bunifu.Framework.UI.BunifuDropdown dpdLanguage;
        private Bunifu.Framework.UI.BunifuDropdown dpdUpdateFrequency;
        private Bunifu.Framework.UI.BunifuCheckbox ckbPlayConverted;
        private System.Windows.Forms.Label text_PlayConvertedVid;
        private System.Windows.Forms.Label text_Num_video_conversion;
        private Bunifu.Framework.UI.BunifuDropdown dpdSimulConversion;
        private Bunifu.Framework.UI.BunifuThinButton2 btnResetWarning;
        private Bunifu.Framework.UI.BunifuImageButton imgbtnSave;
        private Bunifu.Framework.UI.BunifuThinButton2 btnDevConsole;
    }


    Tuesday, January 30, 2018 8:35 PM

Answers

  • You probably need to narrow it down a bit for us. Which line does the debugger crash on?

    That kind of error usually means you have done something like this.

    int myInt;
    public int MyInt
    {
       get{return MyInt;} // Using the wrong casing here (MyInt instead of myInt) creates an infinite loop which exhausts the stack.
    }

    Tuesday, January 30, 2018 10:15 PM
  • Thanks very much! 

    I've correct the error. The problem what just in  a form where i use 

    Form frmM = new frmMain();
    
    public void ect()
    
    {
    
    frmM.Show();
    
    }


    I#m very glad cause this soft will be divided in 50 software!


    Wednesday, January 31, 2018 5:45 PM

All replies

  • You probably need to narrow it down a bit for us. Which line does the debugger crash on?

    That kind of error usually means you have done something like this.

    int myInt;
    public int MyInt
    {
       get{return MyInt;} // Using the wrong casing here (MyInt instead of myInt) creates an infinite loop which exhausts the stack.
    }

    Tuesday, January 30, 2018 10:15 PM
  • Thanks very much! 

    I've correct the error. The problem what just in  a form where i use 

    Form frmM = new frmMain();
    
    public void ect()
    
    {
    
    frmM.Show();
    
    }


    I#m very glad cause this soft will be divided in 50 software!


    Wednesday, January 31, 2018 5:45 PM
  • Thanks you help me !
    Wednesday, January 31, 2018 5:49 PM