Commit 71db340c authored by Marek Vavruša's avatar Marek Vavruša

daemon/worker: decommit memory every 1000nth pool delete

parent d456bd42
......@@ -14,6 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <malloc.h>
#include <uv.h>
#include <libknot/packet/pkt.h>
#include <libknot/internal/net.h>
......@@ -137,6 +138,14 @@ static void qr_task_free(uv_handle_t *handle)
array_push(worker->pools, mp_context);
} else {
mp_delete(mp_context);
#ifdef _GNU_SOURCE
/* Decommit memory every once in a while */
static int mp_delete_count = 0;
if (++mp_delete_count == 1000) {
malloc_trim(0);
mp_delete_count = 0;
}
#endif
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment