You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing an issue with the Python bindings of the library. I am creating an FST and then generating another FST containing the n_best_paths of the original FST.
The problem occurs when I explicitly delete the FSTs. Despite this, the initial FST does not release any memory, and while the FST containing the n_best_paths does free some memory, it doesn't release all of it. This suggests a potential memory leak.
Could you take a look at it?
Code:
importgcimportmathimportrustfstasfstfrommemory_profilerimportprofilefromrustfst.algorithms.shortest_pathimportShortestPathConfigdefcreate_fst():
fa=fst.VectorFst()
start_state=fa.add_state()
fa.set_start(start_state)
current_state=start_stateinput_symbol_table=fst.SymbolTable()
output_symbol_table=fst.SymbolTable()
input_symbol_table.add_symbol("<eps>")
output_symbol_table.add_symbol("<eps>")
foriinrange(1000):
input_symbol_table.add_symbol(str(i))
forjinrange(1, 151):
output_symbol_table.add_symbol(str(j))
# Create 1000 statesforiinrange(1000):
next_state=fa.add_state()
# Create 150 transitions between the current state and the next stateforjinrange(1, 151):
w=-math.log(j*0.005)
fa.add_tr(
current_state,
fst.Tr(
input_symbol_table.find(str(i)),
output_symbol_table.find(str(j)),
w,
next_state,
),
)
current_state=next_statefa.set_final(current_state)
returnfa, input_symbol_table, output_symbol_tabledefget_fst_containing_n_shortest_path(fa: fst.VectorFst, nshortest: int):
res=fa.shortest_path(ShortestPathConfig(nshortest=nshortest))
returnres@profiledefcreate_fst_and_then_get_n_best():
fa, _, _=create_fst()
fb=get_fst_containing_n_shortest_path(fa, nshortest=250)
delfadelfbgc.collect()
defmain():
create_fst_and_then_get_n_best()
if__name__=="__main__":
main()
Hello,
I am experiencing an issue with the Python bindings of the library. I am creating an FST and then generating another FST containing the n_best_paths of the original FST.
The problem occurs when I explicitly delete the FSTs. Despite this, the initial FST does not release any memory, and while the FST containing the n_best_paths does free some memory, it doesn't release all of it. This suggests a potential memory leak.
Could you take a look at it?
Code:
Output of the profiling:
Please note that when deleting fb, only 889MiB from the originally allocated 4447.2 have been released.
Used software:
The text was updated successfully, but these errors were encountered: