title: Why I got this error Not enough memory resources are available to process this command?
body: <p>In my website using ASP.NET MVC + webforms C# and crystal reports ,</p>
  <p>When I click button to print the report using crystal report I got this error</p>
  <p>&quot; Not enough memory resources are available to process this command&quot;</p>
  <p>every 2 days I got this error I solved it by republish the site again , but I need permanent solution</p>
  <p>This is the Code used in webform :</p>
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  
                  TXTORDERID.Text = Request.QueryString[&quot;order_number&quot;].ToString();
                  TXTDEPTID.Text = Request.QueryString[&quot;deptid&quot;].ToString();
                  TXTTESTID.Text = Request.QueryString[&quot;testid&quot;].ToString();
                  TXTCULTURE.Text = Request.QueryString[&quot;Culture&quot;].ToString();
                  
                  ParameterFields paramFields = new ParameterFields();
                  ParameterField paramField = new ParameterField();
                  ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                  ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
                  ParameterField parameterField1 = new ParameterField();
                  ParameterDiscreteValue parameterDiscreteValue1 = new ParameterDiscreteValue();
                  ParameterFields parameterFields = new ParameterFields();
  
  
                  if (Convert.ToInt32(TXTDEPTID.Text) == 7 &amp;&amp; Convert.ToInt32(TXTCULTURE.Text) == 1)
                  {
                      TXTPOSITIVE.Text = Request.QueryString[&quot;Positive&quot;].ToString();
                  }
                  if (Session[&quot;UserCustid&quot;] != null &amp;&amp; Convert.ToInt32(Session[&quot;UserCustid&quot;]) &gt; 0)
                  {
      if (Convert.ToInt32(TXTDEPTID.Text) == 1 || Convert.ToInt32(TXTDEPTID.Text) == 2 || Convert.ToInt32(TXTDEPTID.Text) == 3 || Convert.ToInt32(TXTDEPTID.Text) == 4)
                          {
      
                              paramField.Name = &quot;@ORDER_ID&quot;;
                              paramDiscreteValue.Value = TXTORDERID.Text.ToString();
                              paramField.CurrentValues.Add(paramDiscreteValue);
                              paramFields.Add(paramField);
      
                              paramField = new ParameterField(); // &lt;-- This line is added
                              paramDiscreteValue = new ParameterDiscreteValue();  // &lt;-- This line is added
                              paramField.Name = &quot;@branch_id&quot;;
                              paramDiscreteValue1.Value = TXTDEPTID.Text.ToString();
                              paramField.CurrentValues.Add(paramDiscreteValue1);
                              paramFields.Add(paramField);
      
                              CrystalReportViewer1.ParameterFieldInfo = paramFields;
                              CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;
                              CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
                              reportDocument.Load(Server.MapPath(&quot;~/RPT/RPTCREDITRESULTS.rpt&quot;));
                              CrystalReportViewer1.ReportSource = reportDocument;
                              reportDocument.SetDatabaseLogon(&quot;admin&quot;, &quot;1234&quot;);
                              var connectionInfo = new ConnectionInfo();
                              connectionInfo.ServerName = &quot;desktop&quot;;
                              connectionInfo.DatabaseName = &quot;DBA&quot;;
                              connectionInfo.Password = &quot;1234&quot;;
                              connectionInfo.UserID = &quot;admin&quot;;
                              connectionInfo.Type = ConnectionInfoType.SQL;
                              connectionInfo.IntegratedSecurity = false;
                              for (int i = 0; i &lt; CrystalReportViewer1.LogOnInfo.Count; i++)
                              {
                                  CrystalReportViewer1.LogOnInfo[i].ConnectionInfo = connectionInfo;
                              }
      
                              CrystalReportViewer1.Dispose();
                              
                          }
                          
      
                          if (Convert.ToInt32(TXTDEPTID.Text) == 0)
                          {
      
                              parameterField1.Name = &quot;@ORDER_ID&quot;;
                              parameterDiscreteValue1.Value = (object)this.TXTORDERID.Text.ToString();
                              parameterField1.CurrentValues.Add((ParameterValue)parameterDiscreteValue1);
                              parameterFields.Add(parameterField1);
      
                              //ParameterField parameterField2 = new ParameterField();
                              //ParameterDiscreteValue parameterDiscreteValue2 = new ParameterDiscreteValue();
                              //parameterField2.Name = &quot;@deptid&quot;;
                              //parameterDiscreteValue2.Value = (object)this.TXTDEPTID.Text.ToString();
                              //parameterField2.CurrentValues.Add((ParameterValue)parameterDiscreteValue2);
                              //parameterFields.Add(parameterField2);
                              this.CrystalReportViewer1.ParameterFieldInfo = parameterFields;
                              this.CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;
                              this.CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
                              reportDocument.Load(this.Server.MapPath(&quot;~/RPT/RPTCREDITRESULTS.rpt&quot;));
                              this.CrystalReportViewer1.ReportSource = (object)reportDocument;
                              reportDocument.SetDatabaseLogon(&quot;admin&quot;, &quot;1234&quot;);
      
                              ConnectionInfo connectionInfo = new ConnectionInfo();
                              connectionInfo.ServerName = &quot;desktop&quot;;
                              connectionInfo.DatabaseName = &quot;DBA&quot;;
                              connectionInfo.Password = &quot;1234&quot;;
                              connectionInfo.UserID = &quot;admin&quot;;
                              connectionInfo.Type = ConnectionInfoType.SQL;
                              connectionInfo.IntegratedSecurity = false;
                              for (int index = 0; index &lt; this.CrystalReportViewer1.LogOnInfo.Count; ++index)
                                  this.CrystalReportViewer1.LogOnInfo[index].ConnectionInfo = connectionInfo;
                              CrystalReportViewer1.Dispose();
                          }
  </code></pre>
  <p>this is the error page :</p>
  <p><a href="https://i.stack.imgur.com/9UuI0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9UuI0.jpg" alt="enter image description here" /></a></p>
  <p>I need your kind help please and solve this error and stop receive error on server ?</p>
  <p>I tried to close and dispose the report document but when run the report always got error : object reference not set to an instance an object error</p>
  <p>where I will put the code of close and dispose and not get this error</p>
  <p>object reference not set to an instance an object error?</p>
  <pre><code>reportDocument.Close(); 
  reportDocument.Dispose(); 
  </code></pre>
  <p>I checked this link and changed the value of Printjoblimit to 1500 in server registry is it correct?</p>
  <pre><code>https://blogs.sap.com/2014/04/25/what-exactly-is-maximum-report-processing-job-limit-for-crystal-reports/
  </code></pre>