+/* Set to true to enable memory tracing */
+bool mem_trace = false;
+
+__attribute__((constructor))
+static void
+vac_client_constructor (void)
+{
+ clib_mem_init (0, 1 << 30);
+#if USE_DLMALLOC == 0
+ {
+ u8 *heap;
+ mheap_t *h;
+
+ heap = clib_mem_get_per_cpu_heap ();
+ h = mheap_header (heap);
+ /* make the main heap thread-safe */
+ h->flags |= MHEAP_FLAG_THREAD_SAFE;
+ }
+#endif
+ if (mem_trace)
+ clib_mem_trace (1);
+}
+
+__attribute__((destructor))
+static void
+vac_client_destructor (void)
+{
+ if (mem_trace)
+ fformat(stderr, "TRACE: %s",
+ format (0, "%U\n",
+ format_mheap, clib_mem_get_heap (), 1));
+}
+
+