smcvey / tcz

The Chatting Zone Mud Server
GNU General Public License v2.0
6 stars 3 forks source link

TCZ-39 - Eliminating frequent memory leak as detected by valgrind. #63

Closed noahmanderson closed 2 years ago

noahmanderson commented 2 years ago

I ran TCZ with valgrind for approximately 24 hours, trying a wide variety of things. While some of the output said read sizes varied from initial allocated sizes, the only reports of definitely lost memory traced back to this memory allocated as a part of @returnvalue. This memory appeared to be freed every time a new return value was set, and it also appeared to be freed any time a command was exited. I found that if I freed the memory after it was deep copied as the return value of a command that all reports on valgrind disappeared.

I'll leave this open for a little while in case anybody has better ideas on how to approach this. Can confirm that after this change, there are no "definitely lost" bytes of memory with the exception of the one time allocation of the TCZ prompt, which is of little value freeing one time as TCZ is shutting down.