I tested the following program, which is actually nothing special.
I tested it with valgrind --leak-check=full ./main
. Why am I getting so many errors?
/*
Linux:
gcc main.c -o main -lSDL3
Windows:
x86_64-w64-mingw32-gcc main.c -o main.exe -lSDL3 -I/usr/local/include -L/usr/local/bin
*/
#include <SDL3/SDL.h>
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWindow("An SDL3 window", 640, 480, SDL_WINDOW_OPENGL);
SDL_Delay(3000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
Output:
$ valgrind --leak-check=full ./main
==2878== Memcheck, a memory error detector
==2878== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==2878== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==2878== Command: ./main
==2878==
==2878==
==2878== HEAP SUMMARY:
==2878== in use at exit: 350,549 bytes in 3,376 blocks
==2878== total heap usage: 24,139 allocs, 20,763 frees, 6,086,239 bytes allocated
==2878==
==2878== 29 bytes in 1 blocks are definitely lost in loss record 158 of 2,366
==2878== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x5374F93: ???
==2878== by 0x535AAE7: ???
==2878== by 0x4B27296: SDL_DBus_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B26D7: SDL_InitSubSystem_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B2A2E: SDL_Init_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48E1160: SDL_Init_DEFAULT (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48EE940: SDL_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x1091E5: main (in /n4800/DATEN/Programmierung/mit_GIT/Lazarus/Tutorial/SDL-3/Versuche/C/native_C/SDL3_CreateWindow/main)
==2878==
==2878== 29 bytes in 1 blocks are definitely lost in loss record 159 of 2,366
==2878== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x5374F93: ???
==2878== by 0x535AAAA: ???
==2878== by 0x4B27296: SDL_DBus_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B26D7: SDL_InitSubSystem_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B2A2E: SDL_Init_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48E1160: SDL_Init_DEFAULT (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48EE940: SDL_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x1091E5: main (in /n4800/DATEN/Programmierung/mit_GIT/Lazarus/Tutorial/SDL-3/Versuche/C/native_C/SDL3_CreateWindow/main)
==2878==
==2878== 38 bytes in 1 blocks are definitely lost in loss record 946 of 2,366
==2878== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x5374F93: ???
==2878== by 0x535A8D9: ???
==2878== by 0x4B27296: SDL_DBus_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B26D7: SDL_InitSubSystem_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B2A2E: SDL_Init_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48E1160: SDL_Init_DEFAULT (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48EE940: SDL_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x1091E5: main (in /n4800/DATEN/Programmierung/mit_GIT/Lazarus/Tutorial/SDL-3/Versuche/C/native_C/SDL3_CreateWindow/main)
==2878==
==2878== 72 (24 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 2,302 of 2,366
==2878== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x537CD95: ???
==2878== by 0x5367A45: ???
==2878== by 0x536CD6E: ???
==2878== by 0x535A1B2: ???
==2878== by 0x535A43B: ???
==2878== by 0x535A707: ???
==2878== by 0x4B27296: SDL_DBus_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B26D7: SDL_InitSubSystem_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B2A2E: SDL_Init_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48E1160: SDL_Init_DEFAULT (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48EE940: SDL_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878==
==2878== 520 bytes in 13 blocks are definitely lost in loss record 2,337 of 2,366
==2878== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x5378C8B: ???
==2878== by 0x536C934: ???
==2878== by 0x4B27269: SDL_DBus_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B26D7: SDL_InitSubSystem_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B2A2E: SDL_Init_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48E1160: SDL_Init_DEFAULT (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48EE940: SDL_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x1091E5: main (in /n4800/DATEN/Programmierung/mit_GIT/Lazarus/Tutorial/SDL-3/Versuche/C/native_C/SDL3_CreateWindow/main)
==2878==
==2878== 727 (184 direct, 543 indirect) bytes in 1 blocks are definitely lost in loss record 2,341 of 2,366
==2878== at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x5366DDF: ???
==2878== by 0x5367BF4: ???
==2878== by 0x535A41C: ???
==2878== by 0x535A707: ???
==2878== by 0x4B27296: SDL_DBus_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B26D7: SDL_InitSubSystem_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48B2A2E: SDL_Init_REAL (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48E1160: SDL_Init_DEFAULT (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x48EE940: SDL_Init (in /usr/local/lib/libSDL3.so.0.1.7)
==2878== by 0x1091E5: main (in /n4800/DATEN/Programmierung/mit_GIT/Lazarus/Tutorial/SDL-3/Versuche/C/native_C/SDL3_CreateWindow/main)
==2878==
==2878== 2,302 (736 direct, 1,566 indirect) bytes in 4 blocks are definitely lost in loss record 2,354 of 2,366
==2878== at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2878== by 0x5366DDF: ???
==2878== by 0x5368D6D: ???
==2878== by 0x53718DB: ???
==2878== by 0x5371AAF: ???
==2878== by 0x5372BE0: ???
==2878== by 0x53731CF: ???
==2878== by 0x5358391: ???
==2878== by 0x536D04C: ???
==2878== by 0x535A19D: ???
==2878== by 0x535A43B: ???
==2878== by 0x535A707: ???
==2878==
==2878== LEAK SUMMARY:
==2878== definitely lost: 1,560 bytes in 22 blocks
==2878== indirectly lost: 2,157 bytes in 12 blocks
==2878== possibly lost: 0 bytes in 0 blocks
==2878== still reachable: 346,832 bytes in 3,342 blocks
==2878== suppressed: 0 bytes in 0 blocks
==2878== Reachable blocks (those to which a pointer was found) are not shown.
==2878== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==2878==
==2878== For lists of detected and suppressed errors, rerun with: -s
==2878== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)