Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Call the script like this:
- #
- # ../runtest.sh 2>&1 > /tmp/leak.txt
- # (browse some videos, then CTRL+c to terminate)
- # gstbuffer-leak-analyzer < /tmp/leak.txt
- #
- # This script expects a log like this in stdin:
- #
- # 0:00:21.500314002 402 0x99ca30 LOG GST_BUFFER gstbuffer.c:715:gst_buffer_new: new 0x676a9990
- # 0:00:21.415772804 402 0x99ca30 LOG GST_BUFFER gstbuffer.c:771:gst_buffer_new_allocate: new buffer 0x6762d538 of size 10526 from allocator (nil)
- # 0:00:21.502333117 402 0x99ca30 LOG GST_BUFFER gstbuffer.c:641:_gst_buffer_free: finalize 0x676a9990
- #
- # 0:00:06.529541560 954 0x1d95ac0 DEBUG GST_MEMORY gstmemory.c:138:gst_memory_init: new memory 0x1de31e8, maxsize:2063762 offset:0 size:2063762
- # 0:00:06.529866872 954 0x1d95ac0 DEBUG GST_MEMORY gstmemory.c:87:_gst_memory_free: free memory 0x1aea078
- # ...
- #
- # and will report unbalanced object creation, like this:
- #
- # { 'gstbuffer:': 4 }
- #
- # To get the needed log, you need to enable the proper GStreamer logging when running the browser:
- #
- # export GST_DEBUG="GST_BUFFER:LOG,GST_MEMORY:LOG"
- import sys, pprint
- # Default values
- data = {}
- creates = {}
- destroys = {}
- data['stage'] = 0
- # Input parsing
- for line in sys.stdin:
- if line.find("gst_buffer_new:") != -1:
- fields = line.split()
- obj = "gstbuffer"
- #ptr = fields[7].strip()
- action = "CREATE"
- elif line.find("gst_buffer_free:") != -1:
- fields = line.split()
- obj = "gstbuffer"
- #ptr = fields[7].strip()
- action = "DESTROY"
- elif line.find("gst_memory_init:") != -1:
- fields = line.split()
- obj = "gstmemory"
- #ptr = fields[8].strip();
- action = "CREATE"
- elif line.find("_gst_memory_free:") != -1:
- fields = line.split()
- obj = "gstmemory"
- #ptr = fields[8].strip();
- action = "DESTROY"
- elif line.find("PAUSING VIDEO") != -1:
- data["stage"] = 100;
- elif line.find("DISPOSING SOURCEBUFFER") != -1:
- data["stage"] = 200;
- elif line.find("RESETTING WEBPAGE") != -1:
- data["stage"] = 300;
- else:
- continue;
- if (action == "CREATE"):
- if not(obj in data.keys()):
- creates[obj] = 0
- destroys[obj] = 0
- data[obj] = 0
- data[obj] = data[obj] + 1
- creates[obj] = creates[obj] + 1
- if (action == "DESTROY"):
- data[obj] = data[obj] - 1
- destroys[obj] = destroys[obj] + 1
- try:
- print '"'+str(data["gstbuffer"])+'", "'+str(data["gstmemory"])+'", "'+str(data["stage"])+'"';
- except:
- pass
- print("CREATIONS:")
- pprint.PrettyPrinter(indent=2).pprint(creates)
- print("DESTRUCTIONS:")
- pprint.PrettyPrinter(indent=2).pprint(destroys)
- print("BALANCE:")
- pprint.PrettyPrinter(indent=2).pprint(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement