I want to know whether raylib cleans all the resources on CloseWindow()
call. And if it does not cleans up everything then what remains to be cleaned up manually?
More context: The program turns into a daemon which uses 128K memory. Memory usage goes to approx. 100M when InitWindow()
, BeginDrawing()
, etc. happens. Then EndDrawing()
, and CloseWindow()
are called. But the memory usage drops only around 30M. I expected memory usage to drop to more than that, 128K would be awesome!. Is raylib causing some kind of memory leak? Or there is something that remains to be cleaned up even after calling CloseWindow()
?
Using:
Tried looking up examples and docs. Performed valgrind --leak-check=full
-> found nothing, probably because parent process is terminated after fork()
.
I want to know whether raylib cleans all the resources on
CloseWindow()
call.
It does not.
And if it does not cleans up everything then what remains to be cleaned up manually?
All resources explicitly acquired must be explicitly released. Look at the documentation for every raylib function you've used. A call to initialize the audio device will for example require an explicit call to close the audio device and context.
If you've only called InitWindow()
and BeginDrawing()
, then EndDrawing()
and CloseWindow()
is enough. The high memory usage you observe after that is because the memory is not actually returned to the OS. It's kept since it's much cheaper to reuse memory already acquired by the application than to return it to the OS and then ask for more when needed.