Hi all. I have a few questions about the memory management of libevent.
1) I replaced the memory functions of libvevent using * event_set_mem_functions()* with my own functions and I added a counter for malloc, realloc and free (Yes, I implemented the special cases realloc(NULL, size) and realloc(ptr, 0)). In my http client, while it is downloading webpages, I noticed that the number of allocations only increases. It stops growing for a while, but then it starts growing up again. When I stop the downloads and execute *event_free(base)*, valgrind shows no memory leak. I believe that the memory is freed only at the end. The problem is that my crawler should never stop downloading and, therefore, the memory usage will always increase. a) How can I control the memory usage in libevent? b) I also notice that I can't free a http request, only a http connection. Isn't that the cause of freeing memory being defer? 2) Suggestion: make *event_set_mem_functions()* thread-safe. Libz uses a parameter "void* opaque" that allows client applications to pass a custom data structure to their custom memory functions. Please copy them :). Otherwise, I have to use locks in a multithread application, which greatly drops my performance. Best regards, Bruno