]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: decommit memory every 1000nth pool delete
authorMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 9 Jun 2015 17:06:16 +0000 (19:06 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 9 Jun 2015 17:06:16 +0000 (19:06 +0200)
daemon/worker.c

index 06b165e56d2dae5946d96f70ef51b0b7dfaefa04..fb97ac6a6273f40778629d48598019d0cdd9a4c3 100644 (file)
@@ -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
        }
 }