下面的方法在函数内部向list添加dict元素,然后返回,函数内打印的值结果正常,函数外部打印的值,只有list的第一个元素,请问这是内存被回收了嘛?
def get_invoke_all_methods(method_content, var_name):
invoke_infos = []
results = re.findall("invoke-(.*?)\n", method_content)
if results:
for result in results:
result = str(result).strip()
class_name = result[result.find(", L") + 3:result.rfind(";->")]
method_name = result[result.find("->") + 2:]
info = {"class_name":class_name, "method_name":method_name}
if info not in invoke_infos:
invoke_infos.append(info)
info = None
results = re.findall("get-object(.*?)\n", method_content)
if results:
for result in results:
result = str(result).strip()
if var_name in result:
class_name = result[result.find(", L") + 3:result.rfind(";->")]
method_name = result[result.find("->") + 2:]
info = {"class_name":class_name, "method_name":method_name}
if info not in invoke_infos:
invoke_infos.append(info)
info = None
for invoke in invoke_infos:
print "method inner:" + str(invoke) 在这里打印的值正常
return invoke_infos
函数外部调用
invoke_infos = get_invoke_all_methods(method_content, varname)
if invoke_infos:
for invoke_info in invoke_infos:
print "?????" + str(invoke_info) 在这里打印的值只有list的第一个