Marko Lindqvist writes: > Memory-leak wise S2_4 server seems to be in excellent condition! I > just had server-only autogame running in valgrind for several days. In > the end there was just a bit over 300k of unfreed memory. Seems like > there was no single continuous leak - that 300k is just some buffers > allocated in the beginning, kept in memory and not freed in the end.
Hurrah! A few astring buffers are expected to leak, due to its idiomatic use. >From astring.c: One pattern for using astr_str() is to replace static buffers in functions that return a pointer to static storage. Where previously you would have had e.g. "static struct buf" with an arbitrary size limit, you can have "static struct astring buf", and re-use the same astring on subsequent calls; the caller should behave the same (only reading the string and not freeing it). So instead of tying up storage in a fixed-size static buffer for the convenience of the caller not having to take responsibility for freeing the storage, you're tying up a malloc block of some random size. The malloc block from the last time the function was called will hang around at program exit. I could imagine some of those strings being substantial (e.g., in helper functions for constructing help texts). Perhaps these will be easy to teach valgrind to spot? _______________________________________________ Freeciv-dev mailing list Freecivemail@example.com https://mail.gna.org/listinfo/freeciv-dev