Why does garbage collection not work as intended?

If you do a trace on the process for garbage collection events you will get this information whenever a GC is run: erlang — OTP 29.0.2 (erts 17.0.2)

To start such a trace you can use the runtime_tools module :dbg:

:dbg.tracer(), :dbg.p(pid, [:garbage_collection])

You can also get some information from a running process by calling :erlang.process_info(pid, :garbage_collection_info).