简体   繁体   中英

Why application pool is recycling while reading large excel file on asp.net

I have an asp.net web application. I m reading and processing excel files on it.

Below code shows that how do i read excel files.

            string strComand;
            if (strSheetName.IndexOf("|", StringComparison.Ordinal) > 0)
            {
                _sheetName = strSheetName.Substring(0, strSheetName.IndexOf("|", StringComparison.Ordinal));
                _range = strSheetName.Substring(strSheetName.IndexOf("|", StringComparison.Ordinal) + 1);
                strComand = "select * from [" + _sheetName + "$" + _range + "]";
            }
            else
            {
                strComand = "select * from [" + strSheetName + "]";
            }

            _daAdapter = new OleDbDataAdapter(strComand, _cn); 
            DataTable dt = new DataTable(strSheetName); 
            _daAdapter.FillSchema(dt, SchemaType.Source); 
            GC.Collect();
            GC.WaitForPendingFinalizers();

            _daAdapter.Fill(dt);  // there is a problem on this line
            _cn.Close(); 
            retInfo.Data = dt;  

            return retInfo;

If i read small size excels then there is no problem. But when i tried to read large excel files then my application pool is recycling.

What should i do.

This causes when Application pools are configured to recycle when memory limits are exceeded.

To solve this issue Change the application pool recycling settings in IIS by selecting appropriate application pool.

  1. Open IIs manager console.in the Connections pane, expand the tree view, and then click Application Pools.

  2. In the Application Pools list, right-click the application pool on which you want to disable the memory limits, and then click Recycling.

  3. In the Edit Application Pool Recycling Settings dialog box, in the Memory Based Maximums section, clear the Virtual memory usage (in KB) and Private memory usage (in KB) check boxes, and then click Next.

  4. In the Recycling Events to Log dialog box, click Finish.

Regards, Jalpa.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM