We have a win32 C++ application. We started observing memory leak issue with it when running this application on Windows Server 2016.
We have a hierarchy of exception classes and the base exception class handles the stack trace generation and string conversion for logging.
• When the exceptions are thrown frequently, we see that with the increase in number of exceptions thrown and time, the memory consumption of the service that throws these exceptions increases when the application is running on Windows Server 2016.
E.g. if we keep the service running for 2+ days (regularly throwing exceptions) the consumption reaches 190 MB and continues to increase
• We have traced and listed down the Microsoft APIs that are called when this exception is thrown:
4. RtlCaptureContext( &ctxt )
5. StackWalk64( IMAGE_FILE_MACHINE_I386, process, thread, &frame, &ctxt, NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL )
6. SymSetOptions( SYMOPT_CASE_INSENSITIVE | SYMOPT_LOAD_LINES )
• And below Structures are used:
1. ::STACKFRAME64 frame
2. ::CONTEXT ctxt
• All these APIs are called from a DLL whose methods are invoked when the exception is thrown by the service
• The base exception class definition is also present in the DLL code, whereas the actual derived exception class is defined in the exe code.
We have checked and observed below –
• The issue does not occur on 2012 and 2019 server; hence, the issue is specific to windows server 2016
• We also tried to check if there is any difference between 2012 and 2016 server in terms of allocation and deallocation of resources by these APIs on Microsoft’s official documentation but could not find anything conclusive
Please let me know if more details are required.
Thanks in advance,