Well I'm glad there's at least one coder out there who doesn't make mistakes. You must rake in a fortune to not have any bugs at all!
oh, i still make careless errors - its human nature. but they usually are of the "typo that still compiles" form (stegomastodon_atk_wav=119, not 120), or the result of an API i didn't document thoroughly enough, then use it a year later and forget exactly how it works. but when the code base is pretty stable, and built from components used in many games over many years, you're just doing the same sorts of things over and over with the same sorts of components, so bugs are rare, and usually due to careless errors brought about by haste, due to its all being "old hat".
the last memory related error i had was poor API documentation. Increasing chunk cache size requires additional ground meshes for the additional chunks. i increased chunk size, but didn't assign additional mesh space in the meshes database. as a result, it used the assigned mesh memory for as many chunks as it could, and didn't draw ground meshes for the rest - pretty easy to catch in testing. granted, i could write "safer code" that checked for this condition, but this is a condition that should not occur, so once the code is working right, the check is a waste.
while fixing that, i found a related "typo that compiles" bug. max_qauds_per_ground_mesh was defined as chunksize, not (chunksize/quadsize)*(chunksize/quadsize). this would result in vb's and IB's that were too small. however, this memory is allocated sequentially, so directx had no problems until the mesh memory was used up, and then it simply wouldn't draw ground meshes. this one i hadn't caught yet in testing, as apparently,the cache had never been stressed enough to run out of mesh memory, even with undersized mesh allocations. as testing progressed, i got to the point where i would stress the cache to 100% miss level.
but for me, memory related errors are pretty rare. pretty much everything is in an array[MAXSIZE] and gets accessed via for i=0 i<MAXSIZE i++, so no range check errors. variable size assets are loaded all at once onto the heap sequentially at programs startup, and released at program shutdown. the only other use of the heap i make is a temporary allocation of a 1meg buffer to read in a savegame file for a crc check. the buffer is released at the end of the crc_check function.