Irrespective of your programming language, watching dynamic memory allocation... is a good practice.
As much as possible, allocate all memory at the start and stop there.
Programming languages like C and Zig that force you to make memory allocation explicit are helpful.
In C , try to disable copy constructors for all your classes that allocate memory.
think of malloc/free as so expensive, they might as well be filesystem APIs. use sparingly, like fopen/fclose