Stop freeing everything [2025-10-08]

There is a tendency, or perhaps an addiction, for many programmers to reflexively free every block of memory allocated, every handle opened, every object created. To suggest that anyone do otherwise in maintstream programming discourse is akin blasphemy.

I am humbly requesting you all to stop. Consider the following:

  1. If the operating system is guarenteed to handle a certain behavior (efficiently), it should be left to the OS to handle.
  2. The OS handles freeing memory, handles to objects, etc.
  3. Therefore, please stop doing it
P implies Q. P is true, therefore Q is true.

If something is in use for the entire lifetime of the program, there is no reason to free it unless you have a good reason. Some examples of this would be memory arenas, window handles, module handles, API objects (as an example, OpenGL programs, VBOs, etc.), the list goes on. You can write the code to appropriately free and destroy all these objects, but consider the fact that it costs your time to write, produces absolutely no change in behavior, causes the program to take longer to shutdown (when the OS could more efficiently clean up the mess you created), and bloats the binary. That's all.