I limited the lines of code causing a memory leak to the following useless piece of code obtained from the original windows application.
I already know the general issue