1 | #include <gst/gst.h> |
---|
2 | |
---|
3 | #define ITERS 100 |
---|
4 | #include <stdlib.h> |
---|
5 | |
---|
6 | int |
---|
7 | main (int argc, gchar * argv[]) |
---|
8 | { |
---|
9 | GstElement *element; |
---|
10 | int usage1; |
---|
11 | gint i, iters; |
---|
12 | |
---|
13 | gst_init (&argc, &argv); |
---|
14 | |
---|
15 | if (argc == 2) |
---|
16 | iters = atoi (argv[1]); |
---|
17 | else |
---|
18 | iters = ITERS; |
---|
19 | |
---|
20 | g_print ("starting test\n"); |
---|
21 | |
---|
22 | usage1 = gst_alloc_trace_live_all (); |
---|
23 | //gst_alloc_trace_print_all (); |
---|
24 | |
---|
25 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
26 | gst_object_unref (GST_OBJECT (element)); |
---|
27 | g_print ("create/unref new element %d\n", |
---|
28 | gst_alloc_trace_live_all () - usage1); |
---|
29 | |
---|
30 | for (i = 0; i < iters; i++) { |
---|
31 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
32 | gst_object_unref (GST_OBJECT (element)); |
---|
33 | } |
---|
34 | g_print ("create/unref %d elements %d\n", iters, |
---|
35 | gst_alloc_trace_live_all () - usage1); |
---|
36 | |
---|
37 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
38 | g_assert (GST_OBJECT_FLOATING (element)); |
---|
39 | gst_object_ref (GST_OBJECT (element)); |
---|
40 | gst_object_sink (GST_OBJECT (element)); |
---|
41 | g_assert (!GST_OBJECT_FLOATING (element)); |
---|
42 | gst_object_unref (GST_OBJECT (element)); |
---|
43 | g_print ("create/ref/sink/unref new element %d\n", |
---|
44 | gst_alloc_trace_live_all () - usage1); |
---|
45 | |
---|
46 | |
---|
47 | for (i = 0; i < iters; i++) { |
---|
48 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
49 | gst_object_ref (GST_OBJECT (element)); |
---|
50 | gst_object_sink (GST_OBJECT (element)); |
---|
51 | gst_object_unref (GST_OBJECT (element)); |
---|
52 | } |
---|
53 | g_print ("create/ref/sink/unref %d elements %d\n", iters, |
---|
54 | gst_alloc_trace_live_all () - usage1); |
---|
55 | |
---|
56 | #if 0 |
---|
57 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
58 | g_assert (!GST_OBJECT_DESTROYED (element)); |
---|
59 | gst_object_unref (GST_OBJECT (element)); |
---|
60 | g_assert (GST_OBJECT_DESTROYED (element)); |
---|
61 | gst_object_unref (GST_OBJECT (element)); |
---|
62 | g_print ("create/destroy/unref new element %d\n", |
---|
63 | gst_alloc_trace_live_all () - usage1); |
---|
64 | #endif |
---|
65 | |
---|
66 | #if 0 |
---|
67 | for (i = 0; i < iters; i++) { |
---|
68 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
69 | gst_object_unref (GST_OBJECT (element)); |
---|
70 | gst_object_unref (GST_OBJECT (element)); |
---|
71 | } |
---|
72 | g_print ("create/destroy/unref %d element %d\n", iters, |
---|
73 | gst_alloc_trace_live_all () - usage1); |
---|
74 | #endif |
---|
75 | |
---|
76 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
77 | gst_object_ref (GST_OBJECT (element)); |
---|
78 | gst_object_unref (GST_OBJECT (element)); |
---|
79 | gst_object_unref (GST_OBJECT (element)); |
---|
80 | g_print ("create/ref/unref/unref new element %d\n", |
---|
81 | gst_alloc_trace_live_all () - usage1); |
---|
82 | |
---|
83 | for (i = 0; i < iters; i++) { |
---|
84 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
85 | gst_object_ref (GST_OBJECT (element)); |
---|
86 | gst_object_unref (GST_OBJECT (element)); |
---|
87 | gst_object_unref (GST_OBJECT (element)); |
---|
88 | } |
---|
89 | g_print ("create/ref/unref/unref %d element %d\n", iters, |
---|
90 | gst_alloc_trace_live_all () - usage1); |
---|
91 | |
---|
92 | #if 0 |
---|
93 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
94 | gst_object_ref (GST_OBJECT (element)); |
---|
95 | gst_object_unref (GST_OBJECT (element)); |
---|
96 | gst_object_unref (GST_OBJECT (element)); |
---|
97 | gst_object_unref (GST_OBJECT (element)); |
---|
98 | g_print ("craete/ref/destroy/unref/unref new element %d\n", |
---|
99 | gst_alloc_trace_live_all () - usage1); |
---|
100 | #endif |
---|
101 | |
---|
102 | #if 0 |
---|
103 | for (i = 0; i < iters; i++) { |
---|
104 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
105 | gst_object_ref (GST_OBJECT (element)); |
---|
106 | gst_object_unref (GST_OBJECT (element)); |
---|
107 | gst_object_unref (GST_OBJECT (element)); |
---|
108 | gst_object_unref (GST_OBJECT (element)); |
---|
109 | } |
---|
110 | g_print ("craete/ref/destroy/unref/unref %d elements %d\n", iters, |
---|
111 | gst_alloc_trace_live_all () - usage1); |
---|
112 | #endif |
---|
113 | |
---|
114 | #if 0 |
---|
115 | for (i = 0; i < iters; i++) { |
---|
116 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
117 | gst_object_ref (GST_OBJECT (element)); |
---|
118 | gst_element_set_name (element, "testing123"); |
---|
119 | gst_object_unref (GST_OBJECT (element)); |
---|
120 | gst_element_set_name (element, "testing123"); |
---|
121 | gst_object_unref (GST_OBJECT (element)); |
---|
122 | gst_object_unref (GST_OBJECT (element)); |
---|
123 | } |
---|
124 | g_print ("craete/ref/destroy/unref/unref %d elements with name %d\n", iters, |
---|
125 | gst_alloc_trace_live_all () - usage1); |
---|
126 | #endif |
---|
127 | |
---|
128 | element = gst_element_factory_make ("fakesrc", NULL); |
---|
129 | for (i = 0; i < iters; i++) { |
---|
130 | gst_element_set_name (element, "testing"); |
---|
131 | } |
---|
132 | gst_object_unref (GST_OBJECT (element)); |
---|
133 | g_print ("set name %d times %d\n", iters, |
---|
134 | gst_alloc_trace_live_all () - usage1); |
---|
135 | |
---|
136 | g_print ("leaked: %d\n", gst_alloc_trace_live_all () - usage1); |
---|
137 | |
---|
138 | return (gst_alloc_trace_live_all () - usage1 ? -1 : 0); |
---|
139 | } |
---|