So I decided to run mtrace on Angband to see if any of my sound module code leaked memory.
Turns out Angband leaks like a sieve, but because of z-virt, it is impossible to figure out where the leaks are. mtrace tells me all the unfreed memory was allocated in z-virt.c. Even inlining the mem_*() functions didn't help (now there all allocated in z-virt.h)
So I macro'd mem_alloc to malloc etc, etc. Angband crashed immediately
So z-virt is harmfull for two reasons:
I know checking for NULL after malloc/zalloc is a PITA (there are ~400 instances in the source), but it would allow better memory debugging using standard tools.
Turns out Angband leaks like a sieve, but because of z-virt, it is impossible to figure out where the leaks are. mtrace tells me all the unfreed memory was allocated in z-virt.c. Even inlining the mem_*() functions didn't help (now there all allocated in z-virt.h)
So I macro'd mem_alloc to malloc etc, etc. Angband crashed immediately
So z-virt is harmfull for two reasons:
- It makes it impossible to use mtrace, and;
- It's obviously providing cover for some poor coding practices
I know checking for NULL after malloc/zalloc is a PITA (there are ~400 instances in the source), but it would allow better memory debugging using standard tools.
Comment