2001-05-25 21:00:07 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#define ITERS 100
|
2001-05-25 21:00:07 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
main (int argc, gchar * argv[])
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
|
|
|
GstElement *element;
|
2003-10-15 01:25:41 +00:00
|
|
|
int usage1;
|
2001-05-25 21:00:07 +00:00
|
|
|
gint i, iters;
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
iters = atoi (argv[1]);
|
|
|
|
else
|
|
|
|
iters = ITERS;
|
|
|
|
|
|
|
|
g_print ("starting test\n");
|
2003-10-15 01:25:41 +00:00
|
|
|
|
|
|
|
usage1 = gst_alloc_trace_live_all ();
|
|
|
|
//gst_alloc_trace_print_all ();
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/unref new element %d\n",
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/unref %d elements %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-03-10 12:51:45 +00:00
|
|
|
g_assert (GST_OBJECT_IS_FLOATING (element));
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_sink (GST_OBJECT (element));
|
2005-03-10 12:51:45 +00:00
|
|
|
g_assert (!GST_OBJECT_IS_FLOATING (element));
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/ref/sink/unref new element %d\n",
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_sink (GST_OBJECT (element));
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/ref/sink/unref %d elements %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#if 0
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-03-10 12:51:45 +00:00
|
|
|
g_assert (!GST_OBJECT_IS_DESTROYED (element));
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2005-03-10 12:51:45 +00:00
|
|
|
g_assert (GST_OBJECT_IS_DESTROYED (element));
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/destroy/unref new element %d\n",
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2003-10-15 01:25:41 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#if 0
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/destroy/unref %d element %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2003-10-15 01:25:41 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/ref/unref/unref new element %d\n",
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
|
|
|
|
|
|
|
for (i = 0; i < iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("create/ref/unref/unref %d element %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#if 0
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("craete/ref/destroy/unref/unref new element %d\n",
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2003-10-15 01:25:41 +00:00
|
|
|
#endif
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#if 0
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("craete/ref/destroy/unref/unref %d elements %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2003-10-15 01:25:41 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#if 0
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_ref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_name (element, "testing123");
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_name (element, "testing123");
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
|
|
|
gst_object_unref (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("craete/ref/destroy/unref/unref %d elements with name %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2003-10-15 01:25:41 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesrc", NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_name (element, "testing");
|
|
|
|
}
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (element);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("set name %d times %d\n", iters,
|
|
|
|
gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("leaked: %d\n", gst_alloc_trace_live_all () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return (gst_alloc_trace_live_all () - usage1 ? -1 : 0);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|