In my account were IDE (Microsoft Visual Studio 2017 Community), SDL2 library, and CRT (C Run-time Library). Code for testing.

#include <stdlib.h> #include <crtdbg.h> #include <SDL.h> #include <stdio.h> int main(int argc, char ** argv) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF); _CrtMemState s1; _CrtMemCheckpoint(&s1); SDL_Window *window = NULL; SDL_Renderer *renderer = NULL; SDL_Event event; const uint8_t *cur_key; char *win_name = "demo_name"; int8_t loop = 1; if (SDL_Init(SDL_INIT_EVERYTHING) < 0) printf("ERROR! SDL_INIT\n"); else { if (!(window = SDL_CreateWindow(win_name, 200, 100, 640, 480, SDL_WINDOW_SHOWN))) { printf("ERROR! CREATED WINDOWS FAIL\n"); loop = 0; } else { if (!(renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC))) { printf("ERROR! CREATED RENDERER FAIL\n"); loop = 0; } } } while (loop) { SDL_PollEvent(&event); cur_key = SDL_GetKeyboardState(NULL); if (event.type == SDL_QUIT) loop = 0; if (cur_key[SDL_SCANCODE_ESCAPE]) loop = 0; SDL_SetRenderDrawColor(renderer, 255, 0, 0, 0); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); } if (renderer) SDL_DestroyRenderer(renderer); if (window) SDL_DestroyWindow(window); SDL_Quit(); return 0; } 

The output window provides me with this report:

 Detected memory leaks! Dumping objects -> minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {106} crt block at 0x0163AB10, subtype 0, 1736 bytes long. Data: <p > 70 1F 92 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {101} crt block at 0x08595350, subtype 0, 1736 bytes long. Data: <p > 70 1F 92 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {89} crt block at 0x0168A6D8, subtype 0, 1736 bytes long. Data: <p > 70 1F 92 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {85} crt block at 0x01659108, subtype 0, 1736 bytes long. Data: <p > 70 1F 92 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {83} crt block at 0x016562C8, subtype 0, 1736 bytes long. Data: <p > 70 1F 92 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\lowio\osfinfo.cpp(17) : {2} crt block at 0x0163B208, subtype 0, 3584 bytes long. Data: < > FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 Object dump complete. 

in the case of SDL_DestroyRenderer() functions of SDL_DestroyRenderer() and SDL_DestroyWindow() destructors, the situation worsens

 Detected memory leaks! Dumping objects -> minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {106} crt block at 0x00E3A468, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {105} crt block at 0x0CB789F0, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {103} crt block at 0x0860EAE8, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {101} crt block at 0x086003D8, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {99} crt block at 0x085D3ED0, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {97} crt block at 0x085D2D10, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {95} crt block at 0x085C07D8, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {93} crt block at 0x085BEA40, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {89} crt block at 0x00E8DEC8, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {85} crt block at 0x00E5ACD8, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\internal\per_thread_data.cpp(242) : {83} crt block at 0x00E566C0, subtype 0, 1736 bytes long. Data: <p 1 > 70 1F 31 0F 00 00 00 00 00 00 00 00 00 00 00 00 minkernel\crts\ucrt\src\appcrt\lowio\osfinfo.cpp(17) : {2} crt block at 0x00E3AB60, subtype 0, 3584 bytes long. Data: < > FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 Object dump complete. 

1) How to track memory allocation not using malloc?
2) How to determine what memory the reports indicate?
PS If you have tips on memory management in Win10 I will be grateful for the advice.

Update: By trimming the code itself, to not decent, and using "Dr. Memory"

 #include <SDL.h> int main(int argc, char ** argv) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Quit(); return 0; } 

got the result as

 Error #1: LEAK 264 direct bytes 0x02c356e0-0x02c357e8 + 0 indirect bytes # 0 replace_RtlAllocateHeap [d:\drmemory_package\common\alloc_replace.c:3770] # 1 combase.dll!RoRegisterActivationFactories +0x2e0a (0x74268ebb <combase.dll+0x98ebb>) # 2 combase.dll!CoMarshalInterface +0x34a6 (0x74281447 <combase.dll+0xb1447>) # 3 combase.dll!CoInitializeEx +0x34 (0x742b4ae5 <combase.dll+0xe4ae5>) # 4 SDL2.dll!? +0x0 (0x6c7f69ee <SDL2.dll+0xb69ee>) # 5 SDL2.dll!? +0x0 (0x6c807c5a <SDL2.dll+0xc7c5a>) # 6 SDL2.dll!? +0x0 (0x6c8063d5 <SDL2.dll+0xc63d5>) # 7 SDL2.dll!? +0x0 (0x6c747930 <SDL2.dll+0x7930>) # 8 SDL2.dll!? +0x0 (0x6c74187e <SDL2.dll+0x187e>) # 9 KERNEL32.dll!BaseThreadInitThunk +0x23 (0x73868484 <KERNEL32.dll+0x18484>) 

So I’ll add one more to the two previous questions ...
3) How to get rid of the leak soma SDL2? (if I do not correctly interpret the information I have, correct me)
Just in case, I enclose the FINAL SUMMARY:

 ERRORS FOUND: 0 unique, 0 total unaddressable access(es) 0 unique, 0 total uninitialized access(es) 0 unique, 0 total invalid heap argument(s) 0 unique, 0 total GDI usage error(s) 0 unique, 0 total handle leak(s) 0 unique, 0 total warning(s) 1 unique, 1 total, 264 byte(s) of leak(s) 0 unique, 0 total, 0 byte(s) of possible leak(s) ERRORS IGNORED: 52 potential error(s) (suspected false positives) 15 potential leak(s) (suspected false positives) 361 unique, 483 total, 93492 byte(s) of still-reachable allocation(s) 
  • Dr.Memory, actually analogue of Valgrind drmemory.org - NewView pm
  • @NewView tried this utility, but could not fully deal with it, if you have links to guides I will be very grateful. And indeed, she did not decide ... How to exclude leaks if you do not know what function leads to this? - Igor Michael Stalevskiy
  • And then to understand it, it starts with the keys and in the output directory creates text files of reports, very detailed. If you need startup keys, I can give you an example, although in my opinion everything is clear there. It is better to create a separate topic, then I will give an example of a launch on the topic. - NewView 1:59 pm
  • исключить leaks если не знаешь какая функция - everything is written there in detail with the line number, the name of the function, etc. - NewView
  • Judging by the last log, everything is fine with the memory. The fact that SDL2 stands out there will probably be killed while unloading the library itself, it seems to me that there is nothing to worry about. - NewView

0