Files
create/src/Tools/MemoryLeaks.py
Chris Hennes e2bb84fd2f [Tools] Fix static analyis issues
This commit addresses issues identified by LGTM for the various
independent (and mostly-independent) files in the Tools subdirectory.
The vast majority of the issues are trivial, and are things like unused
imports or catching BaseException. There was one true bug identified, a
global variable being changed in a function where it was not marked
global, but it only affected output quantity (the variable is named
"VERBOSE"). A couple of other issues identified variables that appear to
represent no-longer-existing options in the code. The options were left,
but a deprecation printout replaces the variable in the event the option
is provided.
2021-02-28 17:53:04 +01:00

32 lines
713 B
Python
Executable File

#! python
# -*- coding: utf-8 -*-
# (c) 2006 Werner Mayer LGPL
# FreeCAD report memory leaks script to get provide the log file of Visual Studio in more readable file.
import string,re
# Open the memory leak file
file = open("MemLog.txt")
lines = file.readlines()
file.close()
d=dict()
l=list()
for line in lines:
r=re.search("\\(#\\s*\\d+\\)",line)
if r != None:
s=line[r.start():r.end()]
t=re.search("^Leak",line)
if t != None:
m=d[s]
l.append(m)
else:
d[s]=line
file = open("MemLog_leaks.txt","w")
for line in l:
line = string.replace(line,'Alloc','Leak')
file.write(line)
file.close()