+/*
+ * Copyright 2001-2003 Ximian, Inc
+ * Copyright 2003-2010 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
enum {
PIN_TYPE_STACK,
PIN_TYPE_STATIC_DATA,
PinStatAddress *right;
};
+typedef struct _ObjectList ObjectList;
+struct _ObjectList {
+ MonoObject *obj;
+ ObjectList *next;
+};
+
static PinStatAddress *pin_stat_addresses = NULL;
static size_t pinned_byte_counts [PIN_TYPE_MAX];
+static ObjectList *pinned_objects = NULL;
+
static void
pin_stats_tree_free (PinStatAddress *node)
{
pin_stat_addresses = NULL;
for (i = 0; i < PIN_TYPE_MAX; ++i)
pinned_byte_counts [i] = 0;
+ while (pinned_objects) {
+ ObjectList *next = pinned_objects->next;
+ free_internal_mem (pinned_objects, INTERNAL_MEM_STATISTICS);
+ pinned_objects = next;
+ }
}
static void
pin_stats_register_object (char *obj, size_t size)
{
int pin_types = 0;
+ ObjectList *list = get_internal_mem (sizeof (ObjectList), INTERNAL_MEM_STATISTICS);
pin_stats_count_object_from_tree (obj, size, pin_stat_addresses, &pin_types);
+ list->obj = (MonoObject*)obj;
+ list->next = pinned_objects;
+ pinned_objects = list;
}