The Wayback Machine - https://web.archive.org/web/20210522173359/https://github.com/dotnet/aspnetcore/issues/32884
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0.2] SystemOutOfMemoryException in packages after upgrade to .NET 5 #32884

Open
glararan opened this issue May 20, 2021 · 2 comments
Open

[5.0.2] SystemOutOfMemoryException in packages after upgrade to .NET 5 #32884

glararan opened this issue May 20, 2021 · 2 comments

Comments

@glararan
Copy link

@glararan glararan commented May 20, 2021

Describe the bug

Few days ago I upgraded my custom e-commerce solution based on blazor to .NET 5.0.2 (server has 5.0.3). In few hours memory usage was about 500MB-600MB RAM. If I try to export some data and save to excel (custom package - NPOI) I get SystemOutOfMemoryException. However site is not crashing and keep running, basic request like search/visiting product works just fine.

In following hours I noticed there is another issue - sending emails.. same exception. Thrown by custom package.

I wonder if I missed some setting in upgrade process? Last stable version 3.1.8 had no issues running at 600MB or more.

Server has about 10 GB free memory

Upgrade

App.razor

        <Router AppAssembly="@typeof(Program).Assembly">
to
        <Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
    <TargetFramework>netcoreapp3.1</TargetFramework>
to
    <TargetFramework>net5.0</TargetFramework>

+ package upgrades to 5.0.2 / target Portable AnyCpu

Exceptions (if any)

[ERR] An unhandled exception has occurred while executing the request.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.String.ReplaceHelper(Int32 oldValueLength, String newValue, ReadOnlySpan`1 indices)
   at System.String.Replace(String oldValue, String newValue)
   at NPOI.OpenXml4Net.Util.XmlHelper.EncodeXml(String xml)
   at NPOI.OpenXmlFormats.Spreadsheet.CT_Rst.get_XmlText()
   at NPOI.XSSF.Model.SharedStringsTable.GetKey(CT_Rst st)
   at NPOI.XSSF.Model.SharedStringsTable.AddEntry(CT_Rst st)
   at NPOI.XSSF.UserModel.XSSFCell.SetCellValue(IRichTextString str)
   at NPOI.XSSF.UserModel.XSSFCell.SetCellValue(String str)
   at Ecom.Controllers.Api.ExportApiController.ExportProducts(ExportViewModel model, ISheet excelSheet) in F:\ASP.NET Core\Ecom\src\Controllers\Api\ExportApiController.cs:line 301
   at Ecom.Controllers.Api.ExportApiController.ProcessExport(String fileName, String sheetName, ExportViewModel model, ExportDelegate exportDelegate) in F:\ASP.NET Core\Ecom\src\Controllers\Api\ExportApiController.cs:line 90
   at Ecom.Controllers.Api.ExportApiController.GetExportAsync(ExportViewModel model) in F:\ASP.NET Core\Ecom\src\Controllers\Api\ExportApiController.cs:line 53

Further technical details

  • ASP.NET Core version; 5.0.2
  • Include the output of dotnet --info; 5.0.3
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version; VS 2019.8

Running on IIS 10 Windows Server 2016 x64. AppPool settings: LoadUserProfile: true (no poll memory limit)

@mkArtakMSFT
Copy link
Contributor

@mkArtakMSFT mkArtakMSFT commented May 20, 2021

Thanks for contacting us.
At least from the exception stack trace this doesn't seem to be coming from the framework, rather than your code.
If you believe this is indeed an issue in the framework, we would need to have a minimal repro project (hosted in GitHub) to be able to investigate further.

@glararan
Copy link
Author

@glararan glararan commented May 20, 2021

@mkArtakMSFT Yea stack trace dont call it back to framework. I'll try to gather more info. Maybe there will be leads back to .NET 5. However what is strange is app is not crashing. Why is that? Is there build-in anti-crash protection? Cause I've looked into package source code and I cant find anything about throwing SystemOutOfMemoryException.

At the moment I dont have min repro as I am investigating whats going on exactly. I can only tell I changed following lines vs .NET 3.1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants