Memory_Leak_Check.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 def main():
00004     # Read in the allocation records:
00005     allocate_file = open("/tmp/memory_allocate.log", "r")
00006     allocate_lines = allocate_file.readlines()
00007     allocate_file.close()
00008 
00009     # Read in the free records:
00010     free_file = open("/tmp/memory_free.log", "r")
00011     free_lines = free_file.readlines()
00012     free_file.close()
00013 
00014     free_table = {}
00015     for free_line in free_lines:
00016         free_fields = free_line.split()
00017         free_address = free_fields[0]
00018         #print("free_fields={0}".format(free_fields))
00019         free_table[free_address] = None
00020 
00021     leaks = []
00022     for allocate_line in allocate_lines:
00023         allocate_fields = allocate_line.split()
00024         allocate_address = allocate_fields[0]
00025         allocate_from = allocate_fields[1]
00026         leak = (allocate_address, allocate_from)
00027         if not allocate_address in free_table:
00028             leaks.append(leak)
00029 
00030     leaks.sort()
00031     for leak in leaks:
00032         print("{0}: {1}".format(leak[0], leak[1]))
00033 
00034 main()


fiducial_lib
Author(s): Wayne Gramlich
autogenerated on Thu Jun 6 2019 18:08:04