High RAM Usage Troubleshooting in ASP.NET Core MVC 8 Application
scartus initiates a discussion about high memory usage in an ASP.NET Core MVC 8 application, seeking recommendations and insights from the developer community.
High RAM Usage Troubleshooting in ASP.NET Core MVC 8 Application
Posted by scartus
Problem Statement
An ASP.NET Core MVC 8 app is running on IIS on Windows Server 2025 with 4GB RAM, supporting 50–70 users. The application frequently consumes 2.5GB RAM and experiences out-of-memory errors during business hours. Key workload: users perform database operations (using EF Core), and view case details with thumbnails (10–300KB each) retrieved and generated from a network folder.
Author’s Questions
- Is this level of memory usage normal given the scenario?
- Should the focus be on optimization or hardware upgrade?
- What tools are recommended for analyzing high memory usage, preferably capable of production diagnostics (VS, Rider, others)?
Community Feedback Summary
- Initial Step: Take a memory dump during high memory usage, then analyze with Visual Studio or WinDbg to inspect object counts and sizes.
- Questions to Investigate:
- How are images retrieved or generated? Unmanaged resources such as files or handles might not be disposed properly.
- Is the IIS application pool running in 32-bit mode (limiting max memory)?
- Potential Causes:
- Leaked unmanaged resources (file handles, memory streams not disposed)
- Inefficient or unoptimized EF Core queries loading too much data
- Ineffective caching strategy for thumbnails; suggest static caching or pre-generation
- Site memory limit may be too low for modern web workloads
- Tools for Analysis:
- Visual Studio and Rider for memory profiling
- WinDbg for advanced memory dump inspection
- Use production profilers when possible for most accurate picture
- Best Practices:
- Profile memory allocations and check for leaks
- Confirm app pool is 64-bit where possible
- Optimize database logic, especially loading large collections
- Consider hardware upgrades; 4GB is small by modern standards
- Operational Tips:
- Taking a memory dump pauses the app; use fast local disks to reduce downtime
- Memory issues may appear only in production—rarely reproducible locally
Example Diagnostic Steps
- Initiate a memory dump during high load via Task Manager or dedicated tools
- Analyze dump to identify objects holding memory
- Check code for proper disposal of images, file streams, or other unmanaged resources
- Profile database queries for efficiency
- Review environment (32vs64 bit, memory caps)
- Implement caching strategies for thumbnails, if not already in place
Conclusion
Out-of-memory exceptions indicate a serious issue and are not typical with this workload or user count. Community suggests profiling and code analysis before hardware upgrade, with a focus on identifying leaks, resource handling, and query optimization.
This post appeared first on “Reddit DotNet”. Read the entire article here