mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-13 03:46:34 +00:00
Added a testsuite for refcounting.
Original commit message from CVS: Added a testsuite for refcounting.
This commit is contained in:
parent
fa8e54e450
commit
05a7d639e0
10 changed files with 562 additions and 0 deletions
14
tests/old/testsuite/refcounting/Makefile.am
Normal file
14
tests/old/testsuite/refcounting/Makefile.am
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
testprogs = object element
|
||||||
|
|
||||||
|
object_SOURCES = object.c mem.c
|
||||||
|
element_SOURCES = element.c mem.c
|
||||||
|
|
||||||
|
TESTS = $(testprogs)
|
||||||
|
|
||||||
|
check_PROGRAMS = $(testprogs)
|
||||||
|
|
||||||
|
# we have nothing but apps here, we can do this safely
|
||||||
|
LIBS += $(GST_LIBS)
|
||||||
|
CFLAGS += $(GST_CFLAGS)
|
122
tests/old/testsuite/refcounting/element.c
Normal file
122
tests/old/testsuite/refcounting/element.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#define ITERS 100000
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_element_props (GstElement *element)
|
||||||
|
{
|
||||||
|
g_print ("name %s\n", gst_element_get_name (element));
|
||||||
|
g_print ("flags 0x%08x\n", GST_FLAGS (element));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, gchar *argv[])
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
long usage1, usage2;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
usage1 = vmsize();
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
g_assert (GST_OBJECT_FLOATING (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("sink new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_object_sink (GST_OBJECT (element));
|
||||||
|
g_assert (!GST_OBJECT_FLOATING (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
g_assert (!GST_OBJECT_DESTROYED (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("destroy new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
g_assert (GST_OBJECT_DESTROYED (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
print_element_props (element);
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_element_set_name (element, "testing123");
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
gst_element_set_name (element, "testing123");
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
element = gst_element_new ();
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
gst_element_set_name (element, "testing");
|
||||||
|
}
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("leaked: %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
22
tests/old/testsuite/refcounting/mem.c
Normal file
22
tests/old/testsuite/refcounting/mem.c
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int vmsize() {
|
||||||
|
int pid,fd,size,i,mem;
|
||||||
|
char filename[17], buf[256], *ptr, *end;
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
snprintf(filename,17,"/proc/%d/stat",pid);
|
||||||
|
fd = open(filename,O_RDONLY);
|
||||||
|
size = read(fd,buf,240);
|
||||||
|
ptr = buf;
|
||||||
|
for (i=0;i<22;i++)
|
||||||
|
ptr = (char *)strchr(ptr,' ') + 1;
|
||||||
|
end = (char *)strchr(ptr,' ');
|
||||||
|
*end = 0;
|
||||||
|
sscanf(ptr,"%d",&mem);
|
||||||
|
close(fd);
|
||||||
|
return mem;
|
||||||
|
}
|
1
tests/old/testsuite/refcounting/mem.h
Normal file
1
tests/old/testsuite/refcounting/mem.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
int vmsize();
|
122
tests/old/testsuite/refcounting/object.c
Normal file
122
tests/old/testsuite/refcounting/object.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#define ITERS 100000
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_object_props (GstObject *object)
|
||||||
|
{
|
||||||
|
g_print ("name %s\n", gst_object_get_name (object));
|
||||||
|
g_print ("flags 0x%08lx\n", GST_FLAGS (object));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, gchar *argv[])
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
long usage1, usage2;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
usage1 = vmsize();
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
g_assert (GST_OBJECT_FLOATING (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("sink new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_sink (object);
|
||||||
|
g_assert (!GST_OBJECT_FLOATING (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
g_assert (!GST_OBJECT_DESTROYED (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("destroy new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_destroy (object);
|
||||||
|
g_assert (GST_OBJECT_DESTROYED (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_destroy (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
print_object_props (object);
|
||||||
|
gst_object_destroy (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_destroy (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_set_name (object, "testing123");
|
||||||
|
gst_object_destroy (object);
|
||||||
|
gst_object_set_name (object, "testing123");
|
||||||
|
gst_object_unref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
object = gst_object_new ();
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
gst_object_set_name (object, "testing");
|
||||||
|
}
|
||||||
|
gst_object_unref (object);
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("leaked: %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
14
testsuite/refcounting/Makefile.am
Normal file
14
testsuite/refcounting/Makefile.am
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
SUBDIRS =
|
||||||
|
|
||||||
|
testprogs = object element
|
||||||
|
|
||||||
|
object_SOURCES = object.c mem.c
|
||||||
|
element_SOURCES = element.c mem.c
|
||||||
|
|
||||||
|
TESTS = $(testprogs)
|
||||||
|
|
||||||
|
check_PROGRAMS = $(testprogs)
|
||||||
|
|
||||||
|
# we have nothing but apps here, we can do this safely
|
||||||
|
LIBS += $(GST_LIBS)
|
||||||
|
CFLAGS += $(GST_CFLAGS)
|
122
testsuite/refcounting/element.c
Normal file
122
testsuite/refcounting/element.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#define ITERS 100000
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_element_props (GstElement *element)
|
||||||
|
{
|
||||||
|
g_print ("name %s\n", gst_element_get_name (element));
|
||||||
|
g_print ("flags 0x%08x\n", GST_FLAGS (element));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, gchar *argv[])
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
long usage1, usage2;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
usage1 = vmsize();
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
g_assert (GST_OBJECT_FLOATING (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("sink new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_object_sink (GST_OBJECT (element));
|
||||||
|
g_assert (!GST_OBJECT_FLOATING (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
g_assert (!GST_OBJECT_DESTROYED (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("destroy new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
g_assert (GST_OBJECT_DESTROYED (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
print_element_props (element);
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new element\n");
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
print_element_props (element);
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
g_print ("unref new element %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
element = gst_element_new ();
|
||||||
|
gst_object_ref (GST_OBJECT (element));
|
||||||
|
gst_element_set_name (element, "testing123");
|
||||||
|
gst_object_destroy (GST_OBJECT (element));
|
||||||
|
gst_element_set_name (element, "testing123");
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
element = gst_element_new ();
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
gst_element_set_name (element, "testing");
|
||||||
|
}
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
g_print ("destroy/unref 100000 element %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("leaked: %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
22
testsuite/refcounting/mem.c
Normal file
22
testsuite/refcounting/mem.c
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int vmsize() {
|
||||||
|
int pid,fd,size,i,mem;
|
||||||
|
char filename[17], buf[256], *ptr, *end;
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
snprintf(filename,17,"/proc/%d/stat",pid);
|
||||||
|
fd = open(filename,O_RDONLY);
|
||||||
|
size = read(fd,buf,240);
|
||||||
|
ptr = buf;
|
||||||
|
for (i=0;i<22;i++)
|
||||||
|
ptr = (char *)strchr(ptr,' ') + 1;
|
||||||
|
end = (char *)strchr(ptr,' ');
|
||||||
|
*end = 0;
|
||||||
|
sscanf(ptr,"%d",&mem);
|
||||||
|
close(fd);
|
||||||
|
return mem;
|
||||||
|
}
|
1
testsuite/refcounting/mem.h
Normal file
1
testsuite/refcounting/mem.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
int vmsize();
|
122
testsuite/refcounting/object.c
Normal file
122
testsuite/refcounting/object.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#define ITERS 100000
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_object_props (GstObject *object)
|
||||||
|
{
|
||||||
|
g_print ("name %s\n", gst_object_get_name (object));
|
||||||
|
g_print ("flags 0x%08lx\n", GST_FLAGS (object));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, gchar *argv[])
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
long usage1, usage2;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
usage1 = vmsize();
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
g_assert (GST_OBJECT_FLOATING (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("sink new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_sink (object);
|
||||||
|
g_assert (!GST_OBJECT_FLOATING (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
g_assert (!GST_OBJECT_DESTROYED (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("destroy new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_destroy (object);
|
||||||
|
g_assert (GST_OBJECT_DESTROYED (object));
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_destroy (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
print_object_props (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("creating new object\n");
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
print_object_props (object);
|
||||||
|
gst_object_destroy (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
g_print ("unref new object %ld\n", vmsize()-usage1);
|
||||||
|
gst_object_unref (object);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_destroy (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
object = gst_object_new ();
|
||||||
|
gst_object_ref (object);
|
||||||
|
gst_object_set_name (object, "testing123");
|
||||||
|
gst_object_destroy (object);
|
||||||
|
gst_object_set_name (object, "testing123");
|
||||||
|
gst_object_unref (object);
|
||||||
|
gst_object_unref (object);
|
||||||
|
}
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
object = gst_object_new ();
|
||||||
|
for (i=0; i<ITERS;i++) {
|
||||||
|
gst_object_set_name (object, "testing");
|
||||||
|
}
|
||||||
|
gst_object_unref (object);
|
||||||
|
g_print ("destroy/unref 100000 object %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
g_print ("leaked: %ld\n", vmsize()-usage1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue