fix entity manager factory memory leaks