Memory_Leak_Check.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 def main():
4  # Read in the allocation records:
5  allocate_file = open("/tmp/memory_allocate.log", "r")
6  allocate_lines = allocate_file.readlines()
7  allocate_file.close()
8 
9  # Read in the free records:
10  free_file = open("/tmp/memory_free.log", "r")
11  free_lines = free_file.readlines()
12  free_file.close()
13 
14  free_table = {}
15  for free_line in free_lines:
16  free_fields = free_line.split()
17  free_address = free_fields[0]
18  #print("free_fields={0}".format(free_fields))
19  free_table[free_address] = None
20 
21  leaks = []
22  for allocate_line in allocate_lines:
23  allocate_fields = allocate_line.split()
24  allocate_address = allocate_fields[0]
25  allocate_from = allocate_fields[1]
26  leak = (allocate_address, allocate_from)
27  if not allocate_address in free_table:
28  leaks.append(leak)
29 
30  leaks.sort()
31  for leak in leaks:
32  print("{0}: {1}".format(leak[0], leak[1]))
33 
34 main()


fiducial_lib
Author(s): Wayne Gramlich
autogenerated on Thu Dec 28 2017 04:06:53