Hi @Koteswara Pentakota ,
Thank you for reaching out to Microsoft Q&A for this question.
I understand that you are trying to read large amount of data from MySql DB --> process it in your application --> store it in Excel. Below are some suggestions to investigate this issue. I am assuming that you are using .NET for this application, therefore some of the suggestions are specific to it. However, the underlying concept would work for any other Language/Framework
1. Instead of reading the entire data from MySql DB in application memory, read and process them in batch. For example, you may use reader
related class or use LIMIT
clause with SELECT
statement to read rows in batch of 100/1000/10000 etc.. Refer to this link for details. This would avoid the huge memory requirement only for storing data read from MySql DB. The rows can be processed in smaller batch and writted to Excel sheet.
2. Ensure that Dispose()
and using{}
are used wherever applicable. This would avoid having the objects rooted, even when they are not required and thus Garbage collection would be able to clean them up from memory. ref: Memory release
3. If the steps above do not help, use diagnostic tools like perfview to analyze memory leak. The following post has a great guideline to get started with diagnosing memory leak in Azure App Service - Diagnosing Memory Leaks in Azure App Services with PerfView
4. You might also consider running this application on your VM/on-premise machine with smaller volume of test dataset to observe behavior closely, diagnose and troubleshoot the memory leak issue. There are a number of tools that can help you with it like -
Perfview
Visual Studio
dotnet-dump (dotnet cli based)
Increasing the tier of the application could help with an easy/quick fix, but you might again start facing such issues in future when data volume increases in DB or after adding additinal features. The memory leak should be investigated and memory usage should be optimized for this application. You may also connect with Microsoft Support to seek help in investigating this issue with this application.
Please let me know if you have any questions.
---
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.